Previous Page Arrow Next Page Arrow

7.1 Read Example

Reading a resource is performed by a simple GET operation on the resource URL:

GET /sdata/myApp/myContract/-/salesOrders('43660')?include=orderLines

This request returns the sales order resource as an Atom <entry>. A response to a successful read is:

200 OK
Content-Type: application/atom+xml; type=entry
ETag: gJaGtgHyuAwW6jMI4i0njA
 
<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/-/salesOrders('43660')</id>
  <title>Sales Order 43660</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/-/salesOrders('43660')" />
  <link rel="edit" type="application/atom+xml; type=entry" title="Edit" 
        href="http://www.example.com/sdata/myApp/myContract/-/salesOrders('43660')" />
  <link rel="http://schemas.sage.com/sdata/link-relations/schema" 
        type="application/xml" title="Schema" 
        href="http://www.example.com/sdata/myApp/myContract/-/salesOrders/$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/-/salesOrders/$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/-/salesOrders" />
  <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/-/salesOrders/$service" />

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

  <content>1553,1035</content>

  <sdata:payload>
    <salesOrder 
      sdata:url="http://www.example.com/sdata/myApp/myContract/-/salesOrders('43660')" 
      sdata:key="43660"
      sdata:uuid="44D446D4-5700-41cc-92FB-3BA0FF6017CC"
      xmlns="http://schemas.sage.com/myContract">
      <orderNumber>43660</orderNumber>
      <orderDate>2001-07-01</orderDate>
      <shipDate xsi:nil="true" />
      <contact 
        sdata:url="http://www.example.com/sdata/myApp/myContract/-/contacts('216')" 
        sdata:key="216" 
        sdata:uuid="4AB7DA77-C841-4bef-955A-08D661D86430"
        sdata:lookup="http://www.example.com/sdata/myApp/myContract/-/contacts" />
      <subTotal>7326.5034</subTotal>
      <orderLines 
        sdata:url="http://www.example.com/sdata/myApp/myContract/-/salesOrderLines?where=salesOrderID%20eq%2043660" >
        <salesOrderLine
          sdata:url="http://www.example.com/sdata/myApp/myContract/-/salesOrderLines('43660-1')"
          sdata:key="43660-1"
          sdata:uuid="36B2ECF4-4309-4e62-9878-28DF60B78CFD" >
          <orderNumber>43660</orderNumber>
          <lineNumber>1</lineNumber>
          <product
            sdata:url="http://www.example.com/sdata/myApp/myContract/-/products('758')" 
            sdata:key="758"
            sdata:uuid="455BCC8A-A261-4cf0-A105-599995160C5A"/>
          <orderQty>1</orderQty>
          <unitPrice>874.7940</unitPrice>
        </salesOrderLine>
        <salesOrderLine
          sdata:url="http://www.example.com/sdata/myApp/myContract/-/salesOrderLines('43660-2')"
          sdata:key="43660-2"
          sdata:uuid="CEFE3F52-5529-46b9-A166-79EDFD2D0595" >
          <orderNumber>43660</orderNumber>
          <lineNumber>2</lineNumber>
          <product
            sdata:url="http://www.example.com/sdata/myApp/myContract/-/products('437')" 
            sdata:key="437"
            sdata:uuid="5C9C54FE-B18C-42a9-A0E9-9FEC4BC05C10"/>
          <orderQty>2</orderQty>
          <unitPrice>820.70</unitPrice>
        </salesOrderLine>
      </orderLines>
    </salesOrder>
  </sdata:payload>
  <http:etag>gJaGtgHyuAwW6jMI4i0njA==</http:etag>
</entry>

This is the same entry you would get with the query:

GET /sdata/myApp/myContract/-/salesOrders?where=salesOrderID eq '43660'&include=orderLines

The difference is this query returns the entry inside a <feed> Whereas the read request only returns the <entry> element and the response includes an ETag HTTP header. This is also reflected in the Content-Type header.

The ETag value is returned twice. Once in the ETag header and once in the <http:etag> element. This is normal as we want the request to conform to HTTP rules, which impose the ETag header. And with the SData <feed> structure in which entries contain an <http:etag> element so that they can be edited without having to perform an extra read.

The ETag information is only present if the <a href="../0101/" "1.1 Terminology">resource kind handles concurrent modifications with the ETag mechanism. The service consumer can test the supportsETag schema attribute to find out how the service handles concurrent modifications. See Resource Kind Definitions section for details.
SData providers MUST support read operations on all resource kinds that have the sme:canGet flag set to true. A successful response MUST be an SData entry as described in the Typical Feed Entry section.

Previous Page Arrow Next Page Arrow