Microsoft has recently released preview of Dataverse Custom API. Previously we had Custom Actions which can be called like a custom API. Custom Actions could be bound to a particular entity or remain global/unbound. They were dependent on the workflows and could be treated as a message in the plugin registration tool.
Dataverse custom API is also leveraging the same pattern, however it has some additional capabilities and some differences as well.
- It is not dependent on workflows.
- It can be created as private.
- It is an OData web service with the POST method called an Action and GET method called a Function.
Creating the Dataverse API from maker portal.
Let us create a new solution.
In the solution we will add a ‘Custom API’:
After creating the Custom API, it will not display in the solution. So, we will have to add it to our solution. For adding this click Add existing and then select Custom API from the drop-down list.
It will ask for Name, Description, Binding Type (Global or bound), isFunction(GET or POST), Allowed Custom Processing Type (None, Sync and Async, Async only) etc. Further explanation of these parameters can be found here.
We will then add a request parameter:
and a response property:
If we look at the metadata, we can see our API:
https://{orgname}.crm.dynamics.com/api/data/v9.1/$metadata
Now we will write a plugin for the API:
and register the plugin with the API, please note that we do not need to add a stage to the plugin.
After registering the plugin, we need to set the ‘PluginType’ of the custom API:
Now if we run the function https://{orgname}.crm.dynamics.com/api/data/v9.1/{functionname} in Postman we will see the result.
Please note that Custom API is similar to Custom Actions in some aspects but it has much more control and flexibility in terms of permissions and parameters.
For questions or insights, leave a comment below or reach out to us at info@optimallogics.com. We are always happy to help.