UPDATE

The UPDATE operation modifies existing objects. It updates an object and its child objects. The main parent object (top most) must have a valid object ID.

Note: The UPDATE operation can only update objects by ID and does not support updates by condition.

For a child object, the ID is not required. The child object will be inserted if it does not exist.

Request XML
<request version='1.0'>
  <header>
    <office>myoffice</office>
    <user>jdoe</user>
    <password>password</password>
  </header>
  <update>
    <Contact id="Contact.1.25">
      <LastName>Ryan</LastName>
      <FirstName>Joseph</FirstName>
      <MiddleName>M</MiddleName>
      <Title>Er</Title>
      <TaxID>559658750</TaxID>
      <Person>
        <Dob>1950-02-27</Dob>
        <Gender>1</Gender>
        <Occupation>Medical</Occupation>
        <JobTitle>Chief Of Staff</JobTitle>
        <Marital>1</Marital>
        <Salary>150000</Salary>
      </Person>
      <PreferredPhone>
        <AreaCode>777</AreaCode>
        <Number>1234567</Number>
      </PreferredPhone>
    </Contact>
  </update>
</request>

Response XML

Example 1: PreferredPhone? exists.
<response version="1.0">
  <header>
    <sessionClosed/>
  </header>
  <update>
    <Contact _status="updated" _type="obj" id="Contact.1.25">
      <PreferredPhone _status="updated" _type="obj" id="Phone.1.7"/>
    </Contact>
  </update>
  <_status>OK</_status>
</response>

Example 2: PreferredPhone? does not exist. A new phone object will be added....
<update>
  <Contact id="Contact.123.456" _status="updated">
    <PreferredPhone id="Phone.123.789" _status="inserted"/>
  </Contact>
</update>

To update an object with a child object array, an ID is required. Otherwise, a new object is created.

Example 1: With an ID, the object in the child object array is updated.

Request XML:
<update>
  <Contact id="Contact.1.28">
    <Phones>
      <Phone id="Phone.1.8">
        <AreaCode>99</AreaCode>
        <Number>9999999</Number>
        <Extension>10</Extension>
      </Phone>
    </Phones>
  </Contact>
</update>

Response XML
<response version="1.0">
  <header>
    <sessionClosed/>
  </header>
  <update>
    <Contact _status="updated" _type="obj" id="Contact.1.28">
      <Phones _type="objs">
        <Phone _status="updated" _type="obj" id="Phone.1.8"/>
      </Phones>
    </Contact>
  </update>
  <_status>OK</_status>
</response>

Example 2: Without an ID, the object in the child object array is inserted.

Request XML
<request version='1.0'>
  <header>
    <office/>
    <user/>
    <password/>
  </header>
  <update>
    <Contact id="Contact.1.28">
      <Phones>
        <Phone>
          <AreaCode>07</AreaCode>
          <Number>667788</Number>
          <Extension>#2</Extension>
        </Phone>
      </Phones>
    </Contact>
  </update>
</request>

Response XML
<response version="1.0">
  <header>
    <sessionClosed/>
  </header>
  <update>
    <Contact _status="updated" _type="obj" id="Contact.1.28">
      <Phones _type="objs">
        <Phone _status="inserted" _type="obj" id="Phone.1.9"/>
      </Phones>
    </Contact>
  </update>
  <_status>OK</_status>
</response>



Topic revision: 27 Aug 2015, UnknownUser
 

This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback