Custom APIs in Dataverse is a great way to build your own API messages to encompass complex business operations into a single API. And Power Platform Admin Center provides a great way to keep things simple and yet build your custom APIs just like writing Plugins in Dynamics 365 CRM itself.
Pre Requisites
In order to build your own APIs, you must know the following –
- Writing Plugins in Dynamics 365 CRM – In case you are new to plugin development itself, you can follow this blog series wherein I’ve demonstrated how you can start writing your own C# Plugins for Dynamics 365 CRM.
Link: Plugins Development in Dynamics 365 CRM for Beginners | [Blog Series]
- You’ll also need to know how to connect Postman to your Dynamics 365 CRM environment in order to test your APIs before you can use it in your custom application. I have a blog for the same as well.
Link: Setup Postman to connect to Dynamics 365 CRM using OAuth 2.0 | Azure App Registration
Scenario
Here’s a scenario where I’ll demonstrate how you can use Custom API to do an operation in Dynamics 365 CRM and send back result to the calling application.
- Custom API is exposed to the calling application. Postman in this case.
- Once API is called and parameters is passed, a simple update of a field to an Account will take place.
- Result will be returned to the calling application. Again, Postman in this case.
Create your Custom API & Parameters in Power Platform Admin Center
Let’s create a Custom API that’ll pass on parameters to a plugin and plugin in-turn will send back the result itself –
- Assuming you have created a Solution in the correct Dynamics 365 / Dataverse environment. Click on New, and look for Custom API.

- Give it a suitable Name and fill in the Attributes which are required. Here, the unique name of the API is cf_processaccountapi.
I will cover the other properties in a different blog post.

- Now, I’ll create 2 attributes which I need to pass as parameters to the API call itself.
Hence, I’ll now create 2 new API Request Parameters in the solution by following the below menu.

- First will be the Account Code. I’ll select the Process Account API from the Custom API lookup on the form and then give unique name.
Here, my parameter is of type String.

- And once I save this, this is how my parameter 1 i.e. Account Code is supposed to look.

- Similarly, my second parameter is as follows which accepts a String value. This parameter is called Grade Code. Again, this is just an example. Your scenario could be anything.

- Finally, I’ll also create a Response Property for the Custom API in order to send back the response to the caller.

- And just like how I defined the Request Parameters, I’ll also create the Response property as below.
The form is quite self-explanatory by now.

- Once all of this is done, here’s how my API structure looks like in the solution.

Sample Plugin for Custom API & Registering it using Plugin Registration Tool
Given that you know how to work with Plugins in Dynamics 365 CRM, here’s how you can register the plugin as usual –
- In my plugin, I’m capturing the values from the attributes just like I would identify the context of a Plugin which runs on Update of an Account.

- Then, I’m finding the Account using the Account Code that was passed and updating that Account with the Option Set value which will be the Grade Code.

- Then, once all the processes are done, I’m setting the Output Parameter accountProcessResult with the success message.

- Open the Plugin Registration Tool and log into your environment. Then, Register the Assembly itself.

- Once your plugin has been registered, you’ll need to open the Custom API record again and associate this registered plugin on the Custom API record.
Open the Custom API record which we created above –

- When you associate the Plugin Type, make sure you Save and Publish the customization.
- Now, we will test using Postman. Before we test, notice the Account Grade column which is of type OptionSet – we will update this using the Custom API we built.

The OptionSet fields looks like below –

Testing Using Postman
Now that the code for the Custom API is ready as well as the Plugin too has been registered, let’s test the same using Postman –
- Again, in case you haven’t set the Postman to authenticate and connect to your D365 CRM environment, you can follow this post and set up your Postman to be able to call Dynamics 365 CRM.
Link: Setup Postman to connect to Dynamics 365 CRM using OAuth 2.0 | Azure App Registration
- Now, given that you were able to successfully connect Postman to Dynamics 365, you can do a simple metadata call and check if you connection was successful.

- Now, look at the unique name of the Custom API we created.
Now, switch the method to Post, and append the name of the Custom API itself.
Then, in raw – select JSON type data and construct the JSON to be sent.

- And the result will be returned based on what Output Parameters was set.

- And you’ll see the data on the OptionSet being updated through this example.

Hope this was useful and this helped in clarifying the concept!
Here are some Power Automate posts you want to check out –
- See Trigger Outputs using Edit Columns in Flow Runs | Power Automate [Quick Tip]
- Adding Image field on the form in Dynamics 365 CRM | Power Platform Modern Form Designer [Quick Tip]
- Blocking Attachment Extensions in Dynamics 365 CRM
- Upgrade Dataverse for Teams Environment to Dataverse Environment
- Showing Sandbox or Non Production Apps in Power App mobile app
- Create a Power Apps Per User Plan Trial | Dataverse environment
- Install On-Premise Gateway from Power Automate or Power Apps | Power Platform
- Co-presence in Power Automate | Multiple users working on a Flow
- Search Rows (preview) Action in Dataverse connector in a Flow | Power Automate
- Suppress Workflow Header Information while sending back HTTP Response in a Flow | Power Automate
- Call a Flow from Canvas Power App and get back response | Power Platform\
- FetchXML Aggregation in a Flow using CDS (Current Environment) connector | Power Automate
- Parsing Outputs of a List Rows action using Parse JSON in a Flow | Common Data Service (CE) connector
- Asynchronous HTTP Response from a Flow | Power Automate
- Validate JSON Schema for HTTP Request trigger in a Flow and send Response | Power Automate
- Converting JSON to XML and XML to JSON in a Flow | Power Automate
Thank you!
Like this:
Like Loading...