6.1 Query Example
Queries are performed with anĀ HTTP GET request on a resource kind URL. Here is an example:
GET /sdata/myApp/myContract/-/salesOrders?where=subTotal gt 1500.0&orderBy=orderDate desc&startIndex=21&count=10 &include=orderLines
This query returns the selected orders as an Atom <feed>. It uses URL query parameters to control:
- Which resources are selected by the query, with the where parameter.
- How the feed is sorted, with the orderBy parameter.
- Which page is returned, with the startIndex and count parameters.
- What the payload should include, with the include parameter..
For a complete description of these parameters, see the query parameters section.
The response is a HTTP response containing an Atom <feed>:
200 OK
Content-Type: application/atom+xml; type=feed
<feed xmlns:sdata="http://schemas.sage.com/sdata/2008/1"
xmlns:http="http://schemas.sage.com/sdata/http/2008/1"
xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/"
xmlns:sle="http://www.microsoft.com/schemas/rss/core/2005"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.w3.org/2005/Atom">
<!-- Atom feed elements -->
<title>Sage App | Sales Orders</title>
<id>http://www.example.com/sdata/myApp/myContract/-/salesOrders?where=subTotal gt 1500.0&orderBy=orderDate desc&startIndex=21&count=10
&include=orderLines</id>
<updated>2008-03-31T13:46:45Z</updated>
<!-- Feed level links -->
<link rel="self" type="application/atom+xml; type=feed" title="Refresh"
href="http://www.example.com/sdata/myApp/myContract/-/salesOrders" />
<link rel="first" type="application/atom+xml; type=feed" title="First Page"
href="http://www.example.com/sdata/myApp/myContract/-/salesOrders?startIndex=21&count=10" />
<link rel="last" type="application/atom+xml; type=feed" title="Last Page"
href="http://www.example.com/sdata/myApp/myContract/-/salesOrders?startIndex=31461&count=10" />
<link rel="previous" type="application/atom+xml; type=feed" title="Previous Page"
href="http://www.example.com/sdata/myApp/myContract/-/salesOrders?startIndex=11&count=10" />
<link rel="next" type="application/atom+xml; type=feed" title="Next Page"
href="http://www.example.com/sdata/myApp/myContract/-/salesOrders?startIndex=31&count=10" />
<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" />
<!-- Categories -->
<category scheme="http://schemas.sage.com/sdata/categories"
term="collection" label="Resource Collection"/>
<!-- Paging information -->
<opensearch:totalResults>31465</opensearch:totalResults>
<opensearch:startIndex>21</opensearch:startIndex>
<opensearch:itemsPerPage>10</opensearch:itemsPerPage>
<!-- Simple List Extensions -->
<sle:treatAs>list</sle:treatAs>
<sle:listinfo>
<sle:sort label="ID" default="true" />
<sle:sort ns="http://schemas.sage.com/myContract"
element="salesOrder/orderDate" label="Date" data-type="date" />
<sle:sort ns="http://schemas.sage.com/myContract"
element="salesOrder/shipDate" label="Shipping Date" data-type="date" />
<sle:group ns="http://schemas.sage.com/myContract"
element="salesOrder/contactID" label="Contact" />
</sle:listinfo>
<!-- Atom entry -->
<entry>
<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="self"
href="http://www.example.com/sdata/myApp/myContract/-/salesOrders('43660')" />
<category scheme="http://schemas.sage.com/sdata/categories"
term="resource" label="Resource"/>
<content>Sales order 43660: amount 1553,1035</content>
<!-- Resource payload -->
<sdata:payload>
<salesOrder sdata:key="43660" xmlns="http://schemas.sage.com/myContract">
<orderNumber>43660</orderNumber>
<orderDate>2001-07-01</orderDate>
<shipDate xsi:nil="true" />
<contact sdata:key="216"
sdata:url="http://www.example.com/sdata/myApp/myContract/-/contacts('216')"
sdata:lookup="http://www.example.com/sdata/myApp/myContract/-/contacts"/>
<orderLines sdata:url="http://www.example.com/sdata/myApp/myContract/-/salesOrderLines?where=salesOrderID%20eq%2043660">
<!-- order lines payload skipped to keep example size reasonable -->
</orderLines>
<subTotal>1553.1035</subTotal>
</salesOrder>
</sdata:payload>
<http:etag>gJaGtgHyuAwW6jMI4i0njA==</http:etag>
</entry>
<!-- Atom entry -->
<entry>
<id>http://www.example.com/sdata/myApp/myContract/-/salesOrders('43661')</id>
<title>Sales Order 43661</title>
<updated>2008-03-31T13:46:45Z</updated>
<link rel="self" type="application/atom+xml; type=entry" title="self"
href="http://www.example.com/sdata/myApp/myContract/-/salesOrders('43661')" />
<category scheme="http://schemas.sage.com/sdata/categories"
term="resource" label="Resource"/>
<content>Sales order 43661: amount 39422,1198</content>
<!-- Resource payload -->
<sdata:payload>
<salesOrder sdata:key="43661" xmlns="http://schemas.sage.com/myContract">
<orderNumber>43661</orderNumber>
<orderDate>2001-07-01</orderDate>
<shipDate xsi:nil="true" />
<contact sdata:key="281"
sdata:url="http://www.example.com/sdata/myApp/myContract/-/contacts('281')"
sdata:lookup="http://www.example.com/sdata/myApp/myContract/-/contacts" />
<orderLines sdata:url="http://www.example.com/sdata/myApp/myContract/-/salesOrderLines?where=salesOrderID%20eq%2043661">
<!-- order lines payload skipped to keep example size reasonable -->
</orderLines>
<subTotal>39422.1198</subTotal>
</salesOrder>
</sdata:payload>
<http:etag>3nqPeQqoGoxQB5xf3NIijw==</http:etag>
</entry>
<!-- ... 8 more entries ... -->
</feed>
SData providers MUST support this query protocol on all resource kinds that have the sme:canGet flag set to true. A successful response MUST be an SData feed as described in Anatomy of an SData Feed.


