Web API in D365(Query data) Part - 2

Using Web API, you can retrieve data from Dataverse using Get request. If you are writing client side JavaScript, please follow my previous article. In this article you will see how to prepare queries in Web API.

To get Web API URL and version follow below steps

Go to Advance Settings image.png Navigate to Settings-> Customizations -> Developer Resources

image.png

Web API url

image.png

Example - 1 : Retrieve the accounts entity and using $select return the name property only. If multiple columns to be retrieved use ,(comma). e.g. name,modifiedon

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

Example - 2: Retrieve all the accounts where name is Arindam

GET [Organization URI]/api/data/v9.1/accounts?$select=name$filter=name eq 'arindam'

You can also use contains, starts with, ends with. For more inbuild functions click here

Example -3(Lambda operators):
Retrieve all account entity records that have at least one contact with "Arindam" in the as first name.

GET [Organization URI]api/data/v9.1/accounts?$select=name
&$filter=contact_customer_accounts/any(o:contains(o/firstname,'Arindam'))

o represents each item in dataset. In lamda expression we use x=> x.fieldname. Similarly here we can use o:o/fieldname. In above example you can use all or any.

Example - 4

Retrieve all contacts for a specified Account.

GET [Organization URI]/api/data/v9.1/contacts?$select=fullname
&$filter=parentcustomerid_account/accountid eq 3bd2c3a6-7894-ec11-b400-00224803d449

Example - 5 (Use of Expand)

Using $expand, you can retrieve data from parent record or columns from lookup record. On this example retrieve name column of parentcustomer for a specific contact. parentcustomer is lookup in contact entity.

GET [Organization URI]/api/data/v9.1/contacts(23e9796d-3bbe-ec11-983f-0022480c594f)?$select=fullname
&$expand=parentcustomerid_account($select=name)

Did you find this article valuable?

Support Arindam Saha by becoming a sponsor. Any amount is appreciated!