Introduction
This article will cover using Power Automate to both authenticate and make calls to the Pentana Risk API. Before following through this article, you should have read and understood the Pentana Risk API ensuring that you have the following information ready.
- API Username
- API Password
- Client Name
- Client Secret
1. Generating an Authentication Token
Generating an authentication is done by making a POST request to the /oauth/token endpoint. This call requires the following parameters.
First you will need to create a new flow and within flow you can Initialize your variables, these will be the variables you will need to make the post call. To do this hit the 'add new step' option > search for option variable > Initialize variable. These variables are:
- API Username
- API Password
- Client Name
- Client Secret
Example:
After Variables have been set, please select 'add new step' below the variables and HTTP and select HTTP option. Within HTTP step you are wanting to set up a post request as seen in below image:
You can then save and run flow; this will then provide you an access token to make calls to Pentana Risk site.
Note: The access token will expire after 12 hours from when it was generated.
2. Making API Calls
Now that we have the access token, we can make calls directly against the API using only the token. We'll use Feedback types as an example.
You can can get a list of the available endpoints to make calls by logging into the application and then going to the following URL https://{sitename}.pentanarpm.uk/cpmweb/swagger-ui.html ensuring to update the {sitename} in the URL. Below we will see the endpoints we can use for the Feedback module (For other areas you can expand these module headings to see endpoints available also):
For our example we are going to create a get call to get the feedback types within Site. We will need to first create a new flow and then add 'New Step' within flow for HTTP. Within this HTTP step we are wanting to do a Get Request to be able to see the feedback types within site, next we will need to enter the get request URL which will be site name + the endpoint for getting feedback types (from swagger). the Final step before saving and running this request is to authorize the request with the generated access token, to do this we can enter this within headers (authorization must be bearer authorization). Example of this Request is below:
Comments
0 comments
Please sign in to leave a comment.