Query data using the Web API

If you want to retrieve data for an entity set, use a GET request. When retrieving data, you can apply query options to set criteria for the entity (table) data you want and the entity properties (columns) that should be returned.

Basic query example

This example queries the accounts entity set and uses the $select and $top system query options to return the name property for the first three accounts:

Request

GET [Organization URI]/api/data/v9.2/accounts?$select=name
&$top=3 HTTP/1.1  
Accept: application/json  
OData-MaxVersion: 4.0  
OData-Version: 4.0  
  

Response

HTTP/1.1 200 OK  
Content-Type: application/json; odata.metadata=minimal  
OData-Version: 4.0  
  
{  
   "@odata.context":"[Organization URI]/api/data/v9.2/$metadata#accounts(name)",
   "value":[  
      {  
         "@odata.etag":"W/\"501097\"",
         "name":"Fourth Coffee (sample)",
         "accountid":"89390c24-9c72-e511-80d4-00155d2a68d1"
      },
      {  
         "@odata.etag":"W/\"501098\"",
         "name":"Litware, Inc. (sample)",
         "accountid":"8b390c24-9c72-e511-80d4-00155d2a68d1"
      },
      {  
         "@odata.etag":"W/\"501099\"",
         "name":"Adventure Works (sample)",
         "accountid":"8d390c24-9c72-e511-80d4-00155d2a68d1"
      }
   ]
}
 

Limits on number of table rows (entities) returned

Unless you specify a smaller page size, a maximum of 5000 rows will be returned for each request. If there are more rows that match the query filter criteria, a @odata.nextLink property will be returned with the results. Use the value of the @odata.nextLink property with a new GET request to return the next page of rows.

Note

Queries on entity (table) definitions aren't limited or paged. More information: Query table definitions using the Web API

Use $top query option

You can limit the number of results returned by using the $top system query option. The following example will return just the first three account rows.

GET [Organization URI]/api/data/v9.2/accounts?$select=name,revenue&$top=3  

Note

Limiting results using $top will prevent odata.maxpagesize preference from being applied. You can use odata.maxpagesize preference or $top, but not both at the same time. For more information about odata.maxpagesize, see Specify the number of rows to return in a page.

You should also not use $top with $count.

Specify the number of rows to return in a page

Use the odata.maxpagesize preference value to request the number of rows returned in the response.

Note

You can't use an odata.maxpagesize preference value greater than 5000.

If there are more records that match your criteria, the @odata.nextLink property will be returned with a URL that you can use in a subsequent GET request to get the next page of records matching your criteria.

The following example queries the accounts entity set and returns the name property for the first three accounts.

Request

GET [Organization URI]/api/data/v9.2/accounts?$select=name HTTP/1.1  
Accept: application/json  
OData-MaxVersion: 4.0  
OData-Version: 4.0  
Prefer: odata.maxpagesize=3

Response

HTTP/1.1 200 OK  
Content-Type: application/json; odata.metadata=minimal  
OData-Version: 4.0  
Content-Length: 402
Preference-Applied: odata.maxpagesize=3  
  
{  
   "@odata.context":"[Organization URI]/api/data/v9.2/$metadata#accounts(name)",
   "value":[  
      {  
         "@odata.etag":"W/\"437194\"",
         "name":"Fourth Coffee (sample)",
         "accountid":"7d51925c-cde2-e411-80db-00155d2a68cb"
      },
      {  
         "@odata.etag":"W/\"437195\"",
         "name":"Litware, Inc. (sample)",
         "accountid":"7f51925c-cde2-e411-80db-00155d2a68cb"
      },
      {  
         "@odata.etag":"W/\"468026\"",
         "name":"Adventure Works (sample)",
         "accountid":"8151925c-cde2-e411-80db-00155d2a68cb"
      }
   ],
   "@odata.nextLink":"[Organization URI]/api/data/v9.2/accounts?$select=name&$skiptoken=%3Ccookie%20pagenumber=%222%22%20pagingcookie=%22%253ccookie%2520page%253d%25221%2522%253e%253caccountid%2520last%253d%2522%257b8151925C-CDE2-E411-80DB-00155D2A68CB%257d%2522%2520first%253d%2522%257b7D51925C-CDE2-E411-80DB-00155D2A68CB%257d%2522%2520%252f%253e%253c%252fcookie%253e%22%20/%3E"
}
  

Use the value of the @odata.nextLink property to request the next set of records. Don't change or append any additional system query options to the value. For every subsequent request for additional pages, you should use the same odata.maxpagesize preference value used in the original request. Also, cache the results returned or the value of the @odata.nextLink property so that previously retrieved pages can be returned to.

Note

The value of the @odata.nextLink property is URI encoded. If you URI encode the value before you send it, the XML cookie information in the URL will cause an error.

Apply system query options

Each of the system query options you append to the URL for the entity set is added using the syntax for query strings. The first is appended after [?] and subsequent query options are separated using [&]. All query options are case-sensitive as shown in the following example.

GET [Organization URI]/api/data/v9.2/accounts?$select=name,revenue
&$top=3
&$filter=revenue gt 100000  

Request specific properties

Use the $select system query option to limit the properties returned as shown in the following example.

GET [Organization URI]/api/data/v9.2/accounts?$select=name,revenue  

Important

This is a performance best practice. If properties aren't specified using $select, all properties will be returned.

When you request certain types of properties you can expect additional read-only properties to be returned automatically.

If you request a money value, the _transactioncurrencyid_value lookup property will be returned. This property contains only the GUID value of the transaction currency so you could use this value to retrieve information about the currency using the transactioncurrency EntityType. Alternatively, by requesting annotations you can also get additional data in the same request. More information: Retrieve data about lookup properties

If you request a property that is part of a composite attribute for an address, you will get the composite property as well. For example, if your query requests the address1_line1 property for a contact, the address1_composite property will be returned as well.

Filter results

Use the $filter system query option to set criteria for which rows will be returned.

Standard filter operators

The Web API supports the standard OData filter operators listed in the following table.

Operator Description Example
Comparison Operators
eq Equal $filter=revenue eq 100000
ne Not Equal $filter=revenue ne 100000
gt Greater than $filter=revenue gt 100000
ge Greater than or equal $filter=revenue ge 100000
lt Less than $filter=revenue lt 100000
le Less than or equal $filter=revenue le 100000
Logical Operators
and Logical and $filter=revenue lt 100000 and revenue gt 2000
or Logical or $filter=contains(name,'(sample)') or contains(name,'test')
not Logical negation $filter=not contains(name,'sample')
Grouping Operators
( ) Precedence grouping (contains(name,'sample') or contains(name,'test')) and revenue gt 5000

Note

This is a sub-set of the 11.2.5.1.1 Built-in Filter Operations. Arithmetic operators and the comparison has operator are not supported in the Web API.

All filter conditions for string values are case insensitive.

Standard query functions

The Web API supports these standard OData string query functions:

Function Example
contains $filter=contains(name,'(sample)')
endswith $filter=endswith(name,'Inc.')
startswith $filter=startswith(name,'a')

Note

This is a sub-set of the 11.2.5.1.2 Built-in Query Functions. Date, Math, Type, Geo and other string functions aren't supported in the web API.

Use Wildcard characters in conditions using string values

You can use wildcard characters when you construct queries using these standard query function on string values. More information: Use wildcard characters in conditions for string values

Microsoft Dataverse Web API query functions

Dataverse provides a number of special functions that accept parameters, return Boolean values, and can be used as filter criteria in a query. See Web API Query Function Reference for a list of these functions. The following is an example of the Between Function searching for accounts with a number of employees between 5 and 2000.

GET [Organization URI]/api/data/v9.2/accounts?$select=name,numberofemployees
&$filter=Microsoft.Dynamics.CRM.Between(PropertyName='numberofemployees',PropertyValues=["5","2000"])  

More information: Compose a query with functions.

Use Lambda operators

The Web API allows you to use two lambda operators, which are any and all to evaluate a Boolean expression on a collection.

any operator

The any operator returns true if the Boolean expression applied is true for any member of the collection, otherwise it returns false. The any operator without an argument returns true if the collection is not empty.

Example

The example given below shows how you can retrieve all account entity records that have at least one email with "sometext" in the subject.

GET [Organization URI]/api/data/v9.2/accounts?$select=name
&$filter=Account_Emails/any(o:contains(o/subject,'sometext')) HTTP/1.1
Prefer: odata.include-annotations="*"
Accept: application/json  
OData-MaxVersion: 4.0  
OData-Version: 4.0 

all operator

The all operator returns true if the Boolean expression applied is true for all members of the collection, otherwise it returns false.

Example

The example given below shows how you can retrieve all account entity records that have all associated tasks closed.

GET [Organization URI]/api/data/v9.2/accounts?$select=name
&$filter=Account_Tasks/all(o:o/statecode eq 1) HTTP/1.1
Prefer: odata.include-annotations="*"
Accept: application/json  
OData-MaxVersion: 4.0  
OData-Version: 4.0 

The example given below shows how you can retrieve all account entity records that have at least one email with "sometext" in the subject and whose statecode is active.

GET [Organization URI]/api/data/v9.2/accounts?$select=name
&$filter=Account_Emails/any(o:contains(o/subject,'sometext') and 
o/statecode eq 0) HTTP/1.1
Prefer: odata.include-annotations="*"
Accept: application/json
OData-MaxVersion: 4.0
OData-Version: 4.0

The example given below shows how you can also create a nested query using any and all operators.

GET [Organization URI]/api/data/v9.2/accounts?$select=name
&$filter=(contact_customer_accounts/any(c:c/jobtitle eq 'jobtitle' and 
c/opportunity_customer_contacts/any(o:o/description ne 'N/A'))) and 
endswith(name,'{0}') HTTP/1.1
Prefer: odata.include-annotations="*"
Accept: application/json
OData-MaxVersion: 4.0
OData-Version: 4.0

Filter parent rows (records) based on values of child records

The example given below shows how you can use the /any operator to retrieve all the account records that have:

  • any of their linked opportunity records' budget greater than or equal to 300, and
  • the opportunity records' have no description, or
  • the opportunity records' description contains the term "bad".

Request

GET [Organization URI]/api/data/v9.2/accounts?$select=name
&$filter=not opportunity_customer_accounts/any(o:o/description eq null and 
o/budgetamount le 300 or 
contains(o/description, 'bad')) and 
opportunity_customer_accounts/any() and 
endswith(name,'{0}') HTTP/1.1
Accept: application/json  
OData-MaxVersion: 4.0  
OData-Version: 4.0 

Filter rows (records) based on single-valued navigation property

Navigation properties let you access data related to the current entity. Single-valued navigation properties correspond to Lookup attributes that support many-to-one relationships and allow setting a reference to another entity. More information: Navigation Properties.

You can filter your entity set records based on single-valued navigation property values. For example, you can retrieve child accounts for the specified account.

For example:

  • Retrieve all the matching accounts for a specified Contact ID

    Request

    GET [Organization URI]/api/data/v9.2/accounts?$select=name
    &$filter=primarycontactid/contactid eq a0dbf27c-8efb-e511-80d2-00155db07c77 HTTP/1.1  
    Accept: application/json  
    OData-MaxVersion: 4.0  
    OData-Version: 4.0  
    

    Response

    HTTP/1.1 200 OK  
    Content-Type: application/json; odata.metadata=minimal  
    OData-Version: 4.0  
    
    {  
    "@odata.context":"[Organization URI]/api/data/v9.2/$metadata#accounts(name)",
    "value":[  
           {  
                 "@odata.etag":"W/\"513479\"",
                 "name":"Adventure Works (sample)",
                 "accountid":"3adbf27c-8efb-e511-80d2-00155db07c77"
           },
           {  
                 "@odata.etag":"W/\"514057\"",
                 "name":"Blue Yonder Airlines (sample)",
                 "accountid":"3edbf27c-8efb-e511-80d2-00155db07c77"
           }
        ]
    }  
    
  • Retrieve child accounts for the specified Account ID

    Request

    GET [Organization URI]/api/data/v9.2/accounts?$select=name
    &$filter=parentaccountid/accountid eq 3adbf27c-8efb-e511-80d2-00155db07c77  
    Accept: application/json  
    OData-MaxVersion: 4.0  
    OData-Version: 4.0  
    

    Response

    HTTP/1.1 200 OK  
    Content-Type: application/json; odata.metadata=minimal  
    OData-Version: 4.0  
    
    {  
    "@odata.context":"[Organization URI]/api/data/v9.2/$metadata#accounts(name)",
    "value":[  
           {  
                 "@odata.etag":"W/\"514058\"",
                 "name":"Sample Child Account 1",
                 "accountid":"915e89f5-29fc-e511-80d2-00155db07c77"
           },
           {  
                 "@odata.etag":"W/\"514061\"",
                 "name":"Sample Child Account 2",
                 "accountid":"03312500-2afc-e511-80d2-00155db07c77"
           }
        ]
    }   
    

Filter results based on values of collection-valued navigation properties

Note

It is possible to use $filter within $expand to filter results for related records in a Retrieve operation. You can use a semi-colon separated list of system query options enclosed in parentheses after the name of the collection-valued navigation property. The query options that are supported within $expand are $select, $filter, $top and $orderby. More information: Options to apply to expanded records.

The two options for filtering results based on values of collection-valued navigation properties are:

  1. Construct a query using Lambda operators

    Lambda operators allow you to apply filter on values of collection properties for a link-entity. The below example retrieves the records of systemuser entity type that are linked with team and teammembership entity types, that means it retrieves systemuser records who are also administrators of a team whose name is "CITTEST".

    GET [Organization URI]/api/data/v9.2/systemusers?$filter=(teammembership_association/any(t:t/name eq 'CITTEST'))
    &$select=fullname,businessunitid,title,address1_telephone1,systemuserid
    &$orderby=fullname
    Accept: application/json  
    OData-MaxVersion: 4.0  
    OData-Version: 4.0  
    

    More information: Use Lambda operators.

  2. Iterate over results filtering individual entities based on values in the collection using multiple operations

    To get the same results as the example above, you can retrieve records of two entity types and then iteratively match the values in the collection of one entity to the value in the other entity, thereby filtering entities based on the values in the collection.

    Follow the steps in the below example to understand how we can filter results using the iteration method:

    1. Get a distinct list of team._administratorid_value values.
      • GET [OrganizationURI]/api/data/v9.2/teams?$select=_administratorid_value&$filter=_administrator_value ne null
      • Then loop through the returned values to remove duplicates and get a distinct list. i.e. Create a new array, loop through the query results, for each check to see if they are already in the new array, if not, add them. This should give you a list of distinct systemuserid values
      • The way you would do this in JavaScript vs C# would be different, but essentially you should be able to get the same results.
    2. Query systemuser using ContainValues Query Function to compare the systemuserid values with the list collected in Step 1.

Manage single quotes in string filter values

When specifying values for comparison in filters that accept an array of string values, such as the In Query Function, which contain single quote (apostrophe) characters, such as O'Brian or Men's clothes you must use double quotes around the values. For example:

GET [Organization URI]/api/data/v9.2/contacts?$select=fullname
&$filter=Microsoft.Dynamics.CRM.In(PropertyName=@p1,PropertyValues=@p2)
&@p1='lastname'
&@p2=["OBrian","OBryan","O'Brian","O'Bryan"]

Otherwise you will get the following error: Invalid JSON. A comma character ',' was expected in scope 'Array'. Every two elements in an array and properties of an object must be separated by commas.

If the filter is for a single value, replace the single quote character with two consecutive single quote characters. For example:

GET [Organization URI]/api/data/v9.2/contacts?$select=fullname
&$filter=lastname eq 'O''Bryan'

Otherwise you will get an error like the following: There is an unterminated literal at position 21 in 'lastname eq 'O'Bryan''.

Order results

Specify the order in which items are returned using the $orderby system query option. Use the asc or desc suffix to specify ascending or descending order respectively. The default is ascending if the suffix isn't applied. The following example shows retrieving the name and revenue properties of accounts ordered by ascending revenue and by descending name.

GET [Organization URI]/api/data/v9.2/accounts?$select=name,revenue
&$orderby=revenue asc,name desc
&$filter=revenue ne null  

Aggregate and grouping results

By using $apply you can aggregate and group your data dynamically. Possible use cases with $apply:

Use Case Example
List of unique statuses in the query accounts?$apply=groupby((statuscode))
Count by status values accounts?$apply=groupby((statuscode),aggregate($count as count))
Aggregate sum of the estimated value opportunities?$apply=aggregate(estimatedvalue with sum as total)
Average size of the deal based on estimated value and status opportunities?$apply=groupby((statuscode),aggregate(estimatedvalue with average as averagevalue))
Sum of estimated value based on status opportunities?$apply=groupby((statuscode),aggregate(estimatedvalue with sum as total))
Total opportunity revenue by account name opportunities?$apply=groupby((parentaccountid/name),aggregate(estimatedvalue with sum as total))
Primary contact names for accounts in 'WA' accounts?$apply=filter(address1_stateorprovince eq 'WA')/groupby((primarycontactid/fullname))
Last created record date and time accounts?$apply=aggregate(createdon with max as lastCreate)
First created record date and time accounts?$apply=aggregate(createdon with min as firstCreate)

The aggregate functions are limited to a collection of 50,000 records. Further information around using aggregate functionality with Dataverse can be found here: Use FetchXML to construct a query.

Additional details on OData data aggregation can be found here: OData extension for data aggregation version 4.0. Note that Dataverse supports only a sub-set of these aggregate methods.

Use parameter aliases with system query options

You can use parameter aliases for $filter and $orderby system query options, but currently not inside the $expand option. Parameter aliases allow for the same value to be used multiple times in a request. If the alias isn't assigned a value it is assumed to be null.

Without parameter aliases:

GET [Organization URI]/api/data/v9.2/accounts?$select=name,revenue
&$orderby=revenue asc,name desc
&$filter=revenue ne null  

With parameter aliases:

GET [Organization URI]/api/data/v9.2/accounts?$select=name,revenue
&$orderby=@p1 asc,@p2 desc
&$filter=@p1 ne @p3&@p1=revenue&@p2=name  

You can also use parameter aliases when using functions. More information: Use Web API functions

Retrieve a count of rows

Use the $count system query option with a value of true to include a count of entities that match the filter criteria up to 5000.

Note

The count value does not represent the total number of rows in the system. It is limited by the maximum number of rows that can be returned. More information: Limits on number of rows returned

If you want to retrieve the total number of rows for a table beyond 5000, use the RetrieveTotalRecordCount Function.

The response @odata.count annotation will contain the number of rows, up to 5000, that match the filter criteria irrespective of an odata.maxpagesize preference limitation.

If the count value is 5000 and you want to know whether the count is exactly 5000 or greater than 5000, you can add the Prefer odata.include-annotations="Microsoft.Dynamics.CRM.*" header. This will add the following annotations to the result: @Microsoft.Dynamics.CRM.totalrecordcount and @Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded.

When used together with the $count query option, and there are more than 5000 records you will see these values:

"@odata.count": 5000,
"@Microsoft.Dynamics.CRM.totalrecordcount": 5000,
"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded": true,

If there are fewer than 5000 records, the actual count will be returned.

"@odata.count": 58,
"@Microsoft.Dynamics.CRM.totalrecordcount": 58,
"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded": false,

If you don't include the $count query option, the total @Microsoft.Dynamics.CRM.totalrecordcount value will be -1.

Note

You should not use $top with $count.

The following example shows that there are ten accounts that match the criteria where the name contains "sample", but only the first three accounts are returned.

Request

GET [Organization URI]/api/data/v9.2/accounts?$select=name?
&$filter=contains(name,'sample')
&$count=true HTTP/1.1  
Accept: application/json  
OData-MaxVersion: 4.0  
OData-Version: 4.0  
Prefer: odata.maxpagesize=3
Prefer: odata.include-annotations="Microsoft.Dynamics.CRM.*"

Response

HTTP/1.1 200 OK  
Content-Type: application/json; odata.metadata=minimal  
OData-Version: 4.0  
Preference-Applied: odata.maxpagesize=3
Preference-Applied: odata.include-annotations="Microsoft.Dynamics.CRM.*"
  
{  
   "@odata.context":"[Organization URI]/api/data/v9.2/$metadata#accounts(name)",
   "@odata.count":10,
   "@Microsoft.Dynamics.CRM.totalrecordcount": 5000,
   "@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded": true,
   "value":[  
      {  
         "@odata.etag":"W/\"502482\"",
         "name":"Fourth Coffee (sample)",
         "accountid":"655eaf89-f083-e511-80d3-00155d2a68d3"
      },
      {  
         "@odata.etag":"W/\"502483\"",
         "name":"Litware, Inc. (sample)",
         "accountid":"675eaf89-f083-e511-80d3-00155d2a68d3"
      },
      {  
         "@odata.etag":"W/\"502484\"",
         "name":"Adventure Works (sample)",
         "accountid":"695eaf89-f083-e511-80d3-00155d2a68d3"
      }
   ],
   "@odata.nextLink":"[Organization URI]/api/data/v9.2/accounts?$select=name&$filter=contains(name,'sample')&$skiptoken=%3Ccookie%20pagenumber=%222%22%20pagingcookie=%22%253ccookie%2520page%253d%25221%2522%253e%253caccountid%2520last%253d%2522%257b695EAF89-F083-E511-80D3-00155D2A68D3%257d%2522%2520first%253d%2522%257b655EAF89-F083-E511-80D3-00155D2A68D3%257d%2522%2520%252f%253e%253c%252fcookie%253e%22%20istracking=%22False%22%20/%3E"
}

If you don't want to return any data except for the count, you can apply $count to any collection to get just the value. You cannot apply the Prefer: odata.include-annotations="Microsoft.Dynamics.CRM.*" header in this case because the result is a number, not a collection.

Request

GET [Organization URI]/api/data/v9.2/accounts/$count HTTP/1.1  
Accept: application/json  
OData-MaxVersion: 4.0  
OData-Version: 4.0  

Response

HTTP/1.1 200 OK  
Content-Type: text/plain  
OData-Version: 4.0  
  
10  

Include formatted values

When you want to receive formatted values for properties with the results, use the odata.include-annotations preference with the value of OData.Community.Display.V1.FormattedValue. The response will include these values with properties that match the following naming convention:

<propertyname>@OData.Community.Display.V1.FormattedValue  

The following example queries the accounts entity set and returns the first record, including properties that support formatted values.

Request

GET [Organization URI]/api/data/v9.2/accounts?$select=name,donotpostalmail,accountratingcode,numberofemployees,revenue
&$top=1 HTTP/1.1  
Accept: application/json  
OData-MaxVersion: 4.0  
OData-Version: 4.0  
Prefer: odata.include-annotations="OData.Community.Display.V1.FormattedValue"  

Response

HTTP/1.1 200 OK  
Content-Type: application/json; odata.metadata=minimal  
OData-Version: 4.0  
Preference-Applied: odata.include-annotations="OData.Community.Display.V1.FormattedValue"  
  
{  
   "@odata.context":"[Organization URI]/api/data/v9.2/$metadata#accounts(name,donotpostalmail,accountratingcode,numberofemployees,revenue)",
   "value":[  
      {  
         "@odata.etag":"W/\"502170\"",
         "name":"Fourth Coffee (sample)",
         "donotpostalmail@OData.Community.Display.V1.FormattedValue":"Allow",
         "donotpostalmail":false,
         "accountratingcode@OData.Community.Display.V1.FormattedValue":"Default Value",
         "accountratingcode":1,
         "numberofemployees@OData.Community.Display.V1.FormattedValue":"9,500",
         "numberofemployees":9500,
         "revenue@OData.Community.Display.V1.FormattedValue":"$100,000.00",
         "revenue":100000,
         "accountid":"89390c24-9c72-e511-80d4-00155d2a68d1",
         "transactioncurrencyid_value":"50b6dd7b-f16d-e511-80d0-00155db07cb1"
      }
   ]
}

Use the $expand system query option in the navigation properties to control what data from related entities is returned. More information: Retrieve related table records with a query.

Retrieve data about lookup properties

If your query includes lookup properties you can request annotations that will provide additional information about the data in these properties. Most of the time, the same data is can be derived with knowledge of the single-valued navigation properties and the data included in the related entities. However, in cases where the property represents a lookup attribute that can refer to more than one type of entity, this information can tell you what type of entity is referenced by the lookup property. More information: Lookup properties.

There are two additional types of annotations available for these properties,

Annotation Description
Microsoft.Dynamics.CRM.associatednavigationproperty The name of the single-valued navigation property that includes the reference to the entity.
Microsoft.Dynamics.CRM.lookuplogicalname The logical name of the entity referenced by the lookup.

These properties also can include formatted values as described in Include formatted values. Just like formatted values, you can return the other annotations using the odata.include-annotations preference set to the specific type of annotation you want, or you can set the value to "*" and return all three. The following sample shows the request and response to retrieve information about the incident entity _customerid_value lookup property with annotations included.

Request

GET [Organization URI]/api/data/v9.2/incidents(39dd0b31-ed8b-e511-80d2-00155d2a68d4)?$select=title,_customerid_value
&$expand=customerid_contact($select=fullname) HTTP/1.1  
Accept: application/json  
Content-Type: application/json; charset=utf-8  
OData-MaxVersion: 4.0  
OData-Version: 4.0  
Prefer: odata.include-annotations="*"  

Response

HTTP/1.1 200 OK  
Content-Type: application/json; odata.metadata=minimal  
OData-Version: 4.0  
Preference-Applied: odata.include-annotations="*"  
  
{  
    "@odata.context":"[Organization URI]/api/data/v9.2/$metadata#incidents(title,_customerid_value,customerid_contact(fullname))/$entity",
    "@odata.etag":"W/\"504696\"",
    "_customerid_value@Microsoft.Dynamics.CRM.associatednavigationproperty":"customerid_contact",
    "_customerid_value@Microsoft.Dynamics.CRM.lookuplogicalname":"contact",
    "_customerid_value@OData.Community.Display.V1.FormattedValue":"Susanna Stubberod (sample)",
    "_customerid_value":"7ddd0b31-ed8b-e511-80d2-00155d2a68d4",
    "incidentid":"39dd0b31-ed8b-e511-80d2-00155d2a68d4",
    "customerid_contact":{  
        "@odata.etag":"W/\"503587\"",
        "fullname":"Susanna Stubberod (sample)",
        "contactid":"7ddd0b31-ed8b-e511-80d2-00155d2a68d4"
    }
} 

Use change tracking to synchronize data with external systems

The change tracking feature allows you to keep the data synchronized in an efficient manner by detecting what data has changed since the data was initially extracted or last synchronized. Changes made in entities can be tracked using Web API requests by adding odata.track-changes as a preference header. Preference header odata.track-changes requests that a delta link be returned which can subsequently be used to retrieve entity changes.

More information: Use change tracking to synchronize data with external systems.

Column comparison using the Web API

The following example shows how to compare columns using the Web API:

https://<environment-root>/contacts?$select=firstname&$filter=firstname eq lastname

More information: Use column comparison in queries

See also

Search across table data using Dataverse search
Work with Quick Find's search item limit
Web API Query Data Sample (C#)
Web API Query Data Sample (Client-side JavaScript)
Perform operations using the Web API
Compose Http requests and handle errors
Create a table row using the Web API
Retrieve a table row using the Web API
Update and delete table rows using the Web API
Associate and disassociate table rows using the Web API
Use Web API functions
Use Web API actions
Execute batch operations using the Web API
Impersonate another user using the Web API
Perform conditional operations using the Web API