03 December 2020

The journey into the world of API calls.

Formulated by Jon

Recently, I’ve had a couple of requests which have required me to access some data via an API call. This is something that I’d always shied away from as it seems to be overly complicated and unnecessary but, when it was clear that it was needed, then the time had come to grasp the nettle.

There’s a couple of things that I wanted to highlight as my journey into the world of API calls begins.

Finding an entity’s name

The first one was something that had been bugging me for ages. When I was writing some Flows (because workflows are sooo last year), I had to update some lookup values in there. I know how these need an entity prefix, which refers to the entity as a plural (but not the plural you enter when it’s set up) so, if I want to set an account, I have to begin with ‘accounts/…’. I’d made the silly mistake of naming my entity with an ‘s’ on the end of its schema name (something like ‘prefix_newproducts’) and, no matter what I tried, I couldn’t get my declaration to work. I also had no idea how to find out the method of calling it. Then I discovered the API call to list the entities:


And there it was. All the entities were listed in a way that I could call them. I saw that ‘prefix_newproducts’ had become ‘prefix_newproductses’ so, not only did I sound like Golem from Lord of the Rings when I said it, I was also able to complete my Flow.

Accessing the records

Next, I needed to write a report that was aggregating Case data. Based on how the format the output needed to be in, Power Automate seemed like the best method. So I started by using a recurring Flow, followed by a ‘list’ step and then counting the number of records in the list. This worked for the daily figures as well as the monthly ones but, when it came to the yearly total, the count it gave me was 5000 and all I could think was ‘that’s a handy round number’. It was only when I made some changes to this, and it still came out at 5000 did I realise that this is the maximum number of records this could return.

After much experimenting with splitting the ‘list’ down into various steps (which did work although it never seemed like this was the way it should be done), I decided to do a bit of research. I found that by calling:

https://instance.crm11.dynamics.com/api/data/v9.1/incidents?fetchXml=<fetch aggregate='true'>…</fetch>

I was able to access the data behind the FetchXML call as a chunk of JSON. It was then just a case of putting some aggregation into the call, and there was my figure. Not only did this seem like a much more elegant way of doing this, but it also executed very quickly compared to the multiple ‘list’ steps I’d written.

So I think there’s a lot more to discover with the API calls within Dynamics, but they certainly seem to provide some useful tools.

Get in touch with one of the UK's best Microsoft Dynamics partner

Start your journey towards excellence with Microsoft Dynamics 365

Let us know your details and we'll get in touch with you to learn how we can transform your business processes and operations with Microsoft Dynamics 365 Business Central & Dynamics 365 Customer Engagement:







Protected by GDPR. We'll never share your personal data.

Years established
Happy customers
People supported
Pipers Crisps Co
Aden + Anais
Costa Coffee
Charlton & Jenrick
World Animal Protection

Get in touch


St Mark's Church
St Mark's Road
Wolverhampton WV3 0QH


19 Kingsway House
Team Valley
Gateshead NE11 0HW

Call: 01902 578 300
Skype: Call now

Co. Reg. 03100541
VAT No. GB559725692

Follow us

If you want even more, you can stalk us on any of our social media platforms: