Invoke a MuleSoft RPA Process via HTTP and Postman – Part 2

The Follow-Up: Why Even Invoke a MuleSoft RPA Process via HTTP?

As we learned in the first article in this series, many RPAs need to be callable via HTTP. In these such cases, the RPA process must be published to the Production phase with an invokable run configuration. Credentials (via a Connected App) must be created to authenticate to the RPA API URL and the URL must be retrieved from Anypoint Exchange. Those steps were covered in Part 1 of this 2-part series. The RPA API URL and API Key can be used in Postman to start the execution of the RPA process and to get the status and details of the process execution.

  1. Get the RPA API URL from Exchange and the API Key from RPA Manager, per the steps in Part 1
  2. Create and send a request in Postman to start the process execution
  3. Create and send request(s) in Postman to get process execution status and details

Start RPA Process Execution via Postman

Open Postman and create a PUT request to the URL copied out of Exchange in Part 1:

URL PUT request

Next, go to the Authorization tab. Select Type = “OAuth 2.0”. In “Header Prefix” type “Bearer”. Leave the Token field blank initially; the following steps will go get a new token:

MuleSoft Auth bearer

Scroll down to Configure New Token. In Token Name, enter whatever meaningful name you want to represent this OAuth access token. Select Grant type = “Client Credentials”. For the Access Token URL, type:” https://anypoint.mulesoft.com/accounts/api/v2/oauth2/token”. In Client ID, paste the ID you copied from Anypoint Platform Access Management in Part 1. In Client Secret, paste the Secret that you copied in Part 1. Leave Scope blank, and for Client Authentication, set “Send as Basic Auth header”. Scroll to the bottom of the panel and click the “Get New Access Token” button:

Configure new token

 

Picture of Get New Access Token button

This will use the provided Client ID and Client Secret to go get a new token from the provided Access Token URL. A Postman popup should show that the token was successfully generated and then show a screen for managing access tokens. It shows the access token value. Click Use Token:

Use new token

Once the popup goes away, the token value is now being used in the request for authorization.

Current token data

With a valid token in place, it is time to set up the actual request.

Go to the Body tab. Set it as a “raw” body and set the type = “JSON”.

In the body, specify an “executionId” and the values of any “inputArguments” that you want to set. The executionId is a unique ID that is used to find the status and output data of this specific RPA process execution (one executionId can only be used once). These inputArguments are the input values for the RPA process’s activity parameters; any values not set here are set to the default values configured in the Invokable Run Configuration set up in Part 1 of this series. After setting the payload, hit Send to fire off the request. If everything is configured correctly, a 201 Created status is returned. (Note: If you re-run the PUT command for the same executionId, these follow-up requests will receive 204 No Content statuses as responses, meaning that a new execution was not created.)

Set Body of PUT request

 

Get RPA Process Execution Details via Postman

After sending the PUT request to kick off the RPA process, a GET request can be sent to get the status and details of that process’s execution. As shown in the Exchange page for this RPA process’s REST API asset, there is a GET endpoint for getting these details. The URL is the same endpoint as the prior PUT request URL, except it has “/<executionId>” appended to the end, where executionId equals the executionId sent in the prior PUT request.

After sending a PUT request for executionId = “CloudFirstLabs_Test1”, send a GET request to …/executions/CloudFirstLabs_Test_1. The request should use the same access token as the prior PUT request (Authorization type = “OAuth 2.0”, select the token from the dropdown or paste the token value from the other request). The payload for this request is empty, as it is a pure GET command.

If this GET request is sent immediately after creating the process execution, the response’s message will probably say “The process execution is in status notStarted”.

Start URL in Postman for RPA

If it is sent while the RPA process is executing, the response message will say “The process execution is in status running”.

RPA process status is RUNNING

If the GET request is sent after the RPA process executes successfully, the response message will contain a status of “success” and the result object will hold the values of the RPA process’s activity parameters.

RPA Process execution SUCCESS

Conclusion

By using the steps from Part 1 and Part 2 of this series, we have shown how to enable a MuleSoft RPA process invocation via HTTP and Postman.  This process can be applied to many scenarios and use cases.  Watch the second part of the video here:

Talk to the Professionals!

To learn more about our MuleSoft RPA or Salesforce services, please visit our website or fill out a Contact Us form here.

CloudFirst Labs logo