Program guide > Access data with the REST data service > Request protocols for the REST data service



Retrieve requests with the REST data service

A RetrieveEntity Request is used by a client to retrieve an eXtreme Scale entity. The response payload contains the entity data in AtomPub or JSON format. Also, the system operator $expand can be used to expand the relations. The relations are represented in line within the data service response as an Atom Feed Document, which is a to-many relation, or an Atom Entry Document which is a to-one relation.

Tip: For more details on the RetrieveEntity protocol defined in WCF Data Services, refer to MSDN: RetrieveEntity Request.


Retrive an entity

The following RetrieveEntity example retrieves a Customer entity with key. AtomPub

JSON


Queries

A query can also be used with a RetrieveEntitySet or RetrieveEntity request. A query is specified by the system $filter operator.

For details on the $filter operator, refer to: MSDN: Filter System Query Option ($filter)

The OData protocol supports several common expressions. The eXtreme Scale REST data service supports a subset of the expressions defined in the specification:

The following expressions are not available:

For a complete list and description of the expressions that are available in Microsoft WCF Data Services, see section 2.2.3.6.1.1 : Common Expression Syntax.

The following example demonstrates a RetrieveEntity request with a query. In this example, all customers whose contact name is “RoadRunner” are retrieved. The only customer which matches this filter is Customer('ACME') as shown in the response payload.

Restriction: This query will only work for non-partitioned entities. If Customer is partitioned, then the key belonging to the customer is required.


AtomPub


JSON


System operator $expand

The system operator $expand can be used to expand associations. The associations are represented in line in the data service response. Multi-valued (to-many) associations are represented as an Atom Feed Document or JSON array. Single-valued (to-one) associations, are represented as n Atom Entry Document or JSON object.

For more details on the $expand system operator, refer to Expand System Query Option ($expand).

Here is an example of using the $expand system operator. In this example, we retrieve the entity Customer('IBM')which has an Orders 5000, 5001 and others associated with it. The $expand clause is set to “orders”, so the order collection is expand as inline in the response payload. Only orders 5000 and 5001 are displayed here.


AtomPub


JSON


Parent topic:

Request protocols for the REST data service

Related reference

Retrive non-entities with REST data services

Insert requests with REST data services

Update requests with REST data services

Delete requests with REST data services


+

Search Tips   |   Advanced Search