Site Menu
Mon - Fri 8am - 6pm
Accurate data directly from Companies House UK API, Canvas App and Microsoft Dynamics 365 CRM

Accurate data directly from Companies House UK API, Canvas App and Microsoft Dynamics 365 CRM

Reading time: 2 - 4 minutes

In a recent blog, I wrote a piece around using Power Automate to connect to the Energy Performance Certificate (EPC’s) register and then copying that information directly into Microsoft Dynamics 365 CRM.

This got me thinking... aren’t APIs brilliant! (a nod to Paul Whitehouse & Harry Enfield) So what other APIs are out there (for free) and contain information that would be ‘brilliant’ (okay I’ll stop now) if it was accessible within Microsoft Dynamics 365 CRM?

In an internal meeting, the ‘Companies House UK’ API came up as an idea. I thought almost all businesses need to check Companies house records for some reason. In our case, it would be great to use the API to check a company’s postal address and also confirm the Company number.

After a bit of Googling, I came across ‘flowjoe’ who had already created a video on setting up a custom connector within the Power Platform to query Companies House API.

This video was a good starting point but for me, it missed out on a few key points.

First things first you need to register for an account.

Secondly, it's important to know that Companies House has a Sandbox and Production Environment and therefore two different APIs and then in turn you need different credentials (API keys) for each one.

The final thing that was a 'gotcha' for me was the API Key encryption. When using the Advanced Rest client when you entering your API Key provided by Companies House it actually encrypts it for you in Base64.

What is highlighted above is what you need to paste into the custom connector as shown below.

With the custom connector in place, it was time to add it to a Power Automate flow, to pass it a company name to see what results we got back. My trigger step here was ‘Respond to PowerApp’ and the reason I used this is essentially the name of the company I wanted to search for was coming from a Canvas App (which I explain further down). I then added an action and selected my custom connector.

I saved and ran my flow entering in a company name when prompted and wah-lah! I was presented with a whole load of JSON. This was a good thing! My custom connector was working!

The next step was to parse the JSON (so it was usable), then pass it back (to what is the Canvas app) to using the response action.

The next piece of the puzzle was building a Canvas app to essentially run the flow I had just written, write the results into a Collection, allow the user to select the correct company from the collection and then PATCH this information back into CRM. The reason I had to use a collection is that when we were searching a company name it was bringing back multiple results and therefore I needed a place to store these so the end-user could select the correct company.

Now I know that sounds like a lot of steps but as I have found with Canvas apps, baby steps are the key and don’t worry about how it looks at the beginning that can come later.

By simply adding a button, adding the Power Automate flow to the Canvas app, I would then essentially enter a company name, press the button, the flow would run and the results would be populated in ‘mycollection’.

As you can see above there are lots of Technology Management’s, therefore, we needed the ability to view the information of the correct one.

The next step was to use add the PATCH command to a button write this information back into CRM.

After a bit of back and forth, I finally had it working and was able to embed the Canvas app on the account form within CRM.

This means we can now easily check Companies House data directly from within the comfort of our Account record!

Saving time, effort and most of all removing chance of human error when updating say any information from Companies House. Brilliant! (that was the last one).

Think about this in your place of work, is there a business case for building some integration to save staff from having to repeatedly perform the same task every day? With also giving that invaluable validation? Then maybe try this out for yourself and see how it can benefit your business whilst using Microsoft Dynamics 365 CRM in the future.