Calling a D365FO Web Service from a Flow
Here is a guide on how to call a custom Web Service in D365FO from a Flow. To call a Web Service you need to gain access by retrieving an access token and pass that token in the header of your call.
If you do not have a web service or you want to follow this example, you can download this file and import into your development environment, also you can view this post to see how a web service is made.
Create your flow
Begin by creating your Flow by selecting a template, since I make this flow in relation to my PowerApp post, I will choose the Power Apps button template.
Basic Flow steps
These are the basic steps that you need to call a web service, you can of course do it a whole set of different ways, like use Azure Keyvault or passing parameters instead of hard coding [like I've done here].
Quick explanation:
*Variable, I just hardcoded this, you might choose different approach.
- Called by a power app.
- initialize variables:
- TenantID*
- ClientID*
- Web service URL*
- ProductID, (input parameter from PowerApp), choose the Ask in PowerApps to create input parameter.
- Scope*
- Secret*.
- Retrieve access token
- Compose the result (fetch the token variable from JSON)
- Initialize variable AccessToken, setting the value to the token
- POST run web service. My web service needs JSON, the parameter name is "_data" (underscore included) and the exact parameter name is needed when passing it in the body.
PS! a common mistake here is to not include a whitespace in the Authorization parameter value, there must be a whitespace between the text Bearer and the access token variable.
Comments
Post a Comment