The new Dynamics Web API is a new and amazing tool built into Dynamics 365 creating a much easier way for developers to get information. With the API, you can use HTTP requests to pull data from your Dynamics environment with the power to order, filter, and select as you see fit. However, what if your call is a bit more detailed than something as simple as needing a contact’s address with this specific GUID? The API also gives you the option of pushing fetch XML into the request for cases such as these.

Let’s look at an example: I need all accounts where the primary contact is myself. Simply enough we would construct a call with “‘clientUrl’/api/data/v8.2/accounts?$filter= _primarycontactid_value eq (contact GUID)”. Easy!

dynamics web api

Now, what if it is a bit more detailed? We need all accounts where the primary contact is myself and another specific contact is another contact on a child account. So, we need to look at all the child accounts, then all the contacts on those accounts, and check to see if that contact is on that account.

Doing so with a single API call would prove to be very difficult for us, but we can push fetch XML from advanced find into the API. A call would look like so: “‘clientURL’/api/data/v8.2/accounts?fetchXML=(encoded fetch XML).

dynamics web api

As you can see, with the option of using FetchXML we can get a lot more detailed if need be with linking multiple entities and using those entities with filters as well. It’s a pretty neat tool!

For the latest news and helpful tips for using Dynamics 365, check out our blog!

Happy Dynamics 365’ing!