OData is a protocol, based on
REST, for creating and consuming
data. OData Services are requested with
HTTP GET
requests.
Requesting Data
Return a list (JSON) of all entity sets:
get [Organization URI]/api/data/vx.y
{
"@odata.context":"…data/v8.0/$metadata","value":[
{
"name":"accountleadscollection","kind":"EntitySet","url":"accountleadscollection"
},{
"name":"accounts","kind":"EntitySet","url":"accounts"
},
…
}
get [Organization URI]/api/data/vx.y/EntityDefinitions
get [Organization URI]/api/data/vx.y/EntityDefinitions?$filter=LogicalName eq 'account'
get [Organization URI]/api/data/vx.y/EntityDefinitions?$filter=LogicalName eq 'account'&$select=LogicalCollectionName
A collection of entities:
GET https://Service/path/to/root/ENTITY
An entity that is identified by its id:
GET https://Service/path/to/root/ENTITY('entity-id')
Get a specific property
GET https://Service/path/to/root/ENTITY('entity-id')/PROPERTY
The former request returns a
JSON object. In order to get the
raw value,
$value
can be appended
GET https://Service/path/to/root/ENTITY('entity-id')/PROPERTY/$value
Since properties are hierarchical, it's possible to access specific parts of an entity using a path through the properties:
GET https://Service/path/to/root/ENTITY('entity-id')/TOP-PROPERTY/SUB-PROPERTY/SUB-SUB-PROPERTY
Selecting by a criteria (filtering the result set) with the $filter
keyword:
GET https://Service/path/to/root/ENTITY?$filter=PROPERTY eq 'Value'
$metadata
Gettting metadata (Common Schema Definition Language, CSDL) with
$metadata
. This does not return a JSON object but rather an
XML document.
GET https://Service/path/to/root/$metadata
EntityDefinitions
Return entity definitions as JSON …
GET <SERVICE-ROOT>/EntityDefinitions
… and as XML:
GET <SERVICE-ROOT>/$metadata#EntityDefinitions