{Dynamics CRM/ 365 + Web API} New Metadata Query features in Web API in Dynamics 365

Dynamics 365 is in and just like me, CRM enthusiasts all over the world are simply WOW’ed by its wonderful offerings. After all, this has been a giant leap by Microsoft and indeed a great opportunity for all consultants to me to plunge into unknown territories and conquer it.

In this blog post, I will walk you through the new Metadata Query features that has been introduced with Dynamics 365 Web API. Off late I have been developing some tools using were using the WEB API endpoint and these new additions to the WEB API will really help developers to query the metadata in a very simple way. So without wasting more time, let me straight way give you a flavor of this.

With Dynamics 365, the Web API endpoint has been upgraded to v8.2. So it would be typically in this format – /api/data/v8.2/">https://<organizationUrl>/api/data/v8.2/

For my trial organization, below is the screenshot.


Now comes the interesting part which is querying the metadata.

Below are some of the scenarios I explored and it works like a charm. I will show all the examples here related to the “contact” entity for my organization. The best thing that you find in the below examples is, using the Web API you can query the same way you do in organization service for your CRM Metadata.


Query Entity Metadata


Isn’t it great! You can query the entity metadata using the EntityLogicalName just like you do in Organization Service.

And below is the JSON result I get which you just need to parse to get your data back.



Query Entity Metadata along with all attributes


And below is the sample JSON response for the field ‘First Name’



Querying single Field Metadata

So how about you want to query just a single field metadata. Well dynamics 365 is not here to disappoint you Smile

In the below query, I have just queried for the firstname metadata for the contact entity.


And below is the JSON response.



Querying global Optionsets

Enough of querying fields specific to entity. How about global optionset? And yet again Dynamics 365 has your back.


In the above example, I am querying for the metadata of a global optionset called ‘decisionmaker’. And below is the sample JSON response.



Querying Relationships

The below query will query for the N:N relationship between contact and leads


And below is the JSON response for the same



I am still exploring the wonderful features of Dynamics 365 and stay tuned for another interesting update.


Debajit Dutta

(Visit http://www.xrmforyou.com/products.html and checkout our tools library)

One thought on “{Dynamics CRM/ 365 + Web API} New Metadata Query features in Web API in Dynamics 365”

Leave a Reply