Previous Page Arrow Next Page Arrow

9.4 Update on Property URL

SData also supports updates on property URLs, to update a child of an existing resource. For example, the following request updates an order line of a sales order:

PUT /sdata/myApp/myContract/-/salesOrders('43661')/lines('3')
Content-Type: application/atom+xml; type=entry
If-Match: 2nXz9DZYR2pqmcXi/ZCbYA==
 
<entry xmlns:sdata="http://schemas.sage.com/sdata/2008/1" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns="http://www.w3.org/2005/Atom">
  <id>http://www.example.com/sdata/myApp/myContract/-/salesOrders('43661')/lines('3')</id>
  <title>Sales Order Line 438542</title>
  <salesOrderLine xmlns="http://schemas.sage.com/myContract">
    <orderQty>7</orderQty>
  </salesOrderLine>
</entry>

If the operation succeeds, the service provider sends a response such as:

200 OK
Content-Type: application/atom+xml; type=entry
ETag: STFtZgHEkPz7TyH98YEmWA==
 
<entry xmlns:sdata="http://schemas.sage.com/sdata/2008/1" 
       xmlns:http="http://schemas.sage.com/sdata/http/2008/1" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns="http://www.w3.org/2005/Atom">
  <id>http://www.example.com/sdata/myApp/myContract/-/salesOrderLines('43661-3')</id>
  <title>Sales Order Line 43661-3</title>
  <updated>2008-03-31T13:46:45Z</updated>

  <link rel="self" type="application/atom+xml; type=entry" title="Refresh" 
        href="http://www.example.com/sdata/myApp/myContract/-/salesOrderLines('43661-3')" />
  <link rel="edit" type="application/atom+xml; type=entry" title="Edit" 
        href="http://www.example.com/sdata/myApp/myContract/-/salesOrderLines('43661-3')" />
  <link rel="http://schemas.sage.com/sdata/link-relations/schema" 
        type="application/xml" title="Schema" 
        href="http://www.example.com/sdata/myApp/myContract/-/salesOrderLines/$schema?version=5" />
  <link rel="http://schemas.sage.com/sdata/link-relations/template" 
        type="application/atom+xml; type=entry" title="Template" 
        href="http://www.example.com/sdata/myApp/myContract/-/salesOrderLines/$template" />
  <link rel="http://schemas.sage.com/sdata/link-relations/post" 
        type="application/atom+xml; type=entry" title="Post" 
        href="http://www.example.com/sdata/myApp/myContract/-/salesOrderLines" />
  <link rel="http://schemas.sage.com/sdata/link-relations/service" 
        type="application/atom+xml; type=feed" title="Service" 
        href="http://www.example.com/sdata/myApp/myContract/-/salesOrderLines/$service" />

  <category scheme="http://schemas.sage.com/sdata/categories" 
            term="resource" label="Resource"/>

  <content>Order line 43661-3</content>

  <sdata:payload>
    <salesOrderLine xmlns="http://schemas.sage.com/myContract"
        sdata:uuid="E6A0CB39-429D-4f79-8687-44DCDA81743B"
        sdata:key="43661-3"
        sdata:url="http://www.example.com/sdata/myApp/myContract/-/salesOrderLines('43661-3')"/>
      <orderNumber>43660</orderNumber>
      <lineNumber>3</lineNumber>
      <product 
        sdata:key="21"
        sdata:url="http://www.example.com/sdata/myApp/myContract/-/products('21')" />
      <orderQty>7</orderQty>
      <unitPrice>13.50</unitPrice>
    </salesOrderLine>
  </sdata:payload>
  <http:etag>cXi/ZCbYA2nXz9DZYR2pqm==</http:etag>
</entry>

This feature is restricted to properties that represent parent/child relationships (properties marked with sme:relationship=”child” in the schema).

Relationship properties that support this feature MUST also be flagged with canPut=”true” in the schema.

The service should favour a primary URL over a hierachical URL for the id of the created resource (salesOrderLines(‘43661-3’) rather than salesOrders(‘43661’)/orderLines(‘3’)). This is consistent with the recommendations given in the Querying Property URLs and Reading Property URLs sections.

SData providers MAY support update operations on property URLs. They MUST support them on all the properties that are flagged with sme:canPut="true" in the schema.

Previous Page Arrow Next Page Arrow