While querying data using Dynamics CRM 2016 Web API you may require to get the additional information associated with lookup field in the selected entity (Right now only ID of the lookup record will return in response). Although calling Web API is very straight forward in Dynamics CRM 2016 but to retrieve the data associated with Lookup field you would need to pass the additional headers with every API request.
Overview of this scenario is explained here – Retrieve data about lookup properties
In this blog I am going to demonstrate with you the request creation for this type of API call, before that let’s look at the output of the request to opportunities entity where Account & Contact are the lookup fields
To save the time I have used the postman app inside chrome browser.
JSON response contains “_parentaccountid_value” which is record id of the associated account.
Now call the same request with following additional headers,
And observe the response with addition information about Contact & Account lookup field, the response contains additional attribute of lookup logical name and formatted value.
Let’s call the same API request from java script web resource with the help of XMLHttpRequest() object, You can refer following piece of code