Power Automate – Connecting to the Acumatica REST API
Are you an avid Power Automate User looking to connect to Acumatica but ran into roadblocks creating a Power Automate Custom Connector? Or starting anew and looking for some guidance? You are not alone!
The answer to this topic has been somewhat elusive. So, we felt it would be good to share this to anyone looking to get up and running quickly. Acumatica hasn’t recently published specific steps on how to authenticate with Power Automate and Microsoft disabled some functionality a few years ago that may have you ready to pull your hair out.
First off, create your Power Automate Flow that we are going to use. We will make this extremely simple for the example. We will have the following actions in this flow:
- LOGIN – HTTP GET
- Parse JSON – Parse out the Access_Code for future use.
- GET – Go after the details that we are looking for.
- LOGOUT – Making sure that we do the logout routine. If we don’t, we leave an API user open and could cause problems.
Acumatica Pre Work:
We need to obtain authorization details so that we can connect to our Acumatica Tenant. The method to do this is to create a Connected Application in Acumatica. The process is simple:
- Within your Acumatica Tenant, go to Connected Applications.
- Select “+” to create a new application.
- Give this Connected Application a Client Name that is recognizable.
- For OAuth 2.0 Flow, choose: Resource Owner Password Credentials
- Create the secret by choosing Add Shared Secret button.
- Give the secret a description and expiration date.
- Store the Secret in a secure place as you cannot retrieve this value after pressing OK.
- Once you press OK on the “Add Shared Secret” window, make sure to save the Connected Application.
Now that we have created our Connected Application, we can start setting up our Flow. At a high level, our FLOW will have a visual of the following:
The first step we will dig into is the LOGIN. In this step, using Oauth authentication, we need to have the following parameters available. This will require us to have setup a Connected Application within Acumatica which was explained above:
Client_ID – @ Example: C3DBAC00-10E5-4C11-B95D-A984F9655C2A@SweetLife
Client_Secret – -> This is the Secret we saved from the Connected Application. Example -> YYlf5y9BcuCcoLxsn6FDwg
Tenant – -> Login Name of the Tenant you are connecting to. This will be found in the Tenants Screen. Example -> SweetLife
Username – -> This will be a User that has API access to the Tenant
Password – -> Password for the User.
These items above will be used in the following code that will be placed into the Body of the HTTP GET request:
This detail will be placed in the body of the HTTP Request, which in this HTTP POST example I have named Login:
Once you have completed the Login action, you are good to move on to the next action.
PARSE JSON to get Access_Token for GET Request:
The next step in the flow will be to parse out the Access_Code from the previous actions output. We do this in the following method:
- Create a Parse JSON Action
- Add the Login Body to the Content
- Click the “Generate from sample” for Schema and enter in the following details and click done.
- Schema that we will use as a sample:
Note: Make sure the JSON you get looks like the above with four lines and not the other larger JSON output.
This is all that we need to do to capture the Access_Token that we will use in the next step.
GET Request – in this action, we will be passing the Access Token that is returned to us in the Parse JSON Action. Here are the steps to achieve this:
- Create a HTTP GET Action
- URI will be the URI of the endpoint you want to go after, for example: https://tenantdomain/tenantname/entity/Default/17.200.001/Vendor
- Under Headers, we should have the following:
This is all that is required to run a HTTP GET action.
Logout – VERY Important, do not forget to add this step as you may run into login issues due to using up all your API sessions.
- Create an HTTP POST Request
- URI: https://domainoftenant/tenantname/entity/logout
- Under the Headers section, you will have the same at the previous.
Overall, this is a simple process but when it’s not documented it can take time. We hope that this helps you shortcut your journey to using Power Automate to leverage the flexibility of the Acumatica platform. Please reach out to our team for any help or questions.
Time for a SQL Health Check?
Yes, it is. Your business future relies on SQL Server. Contact the Najaxa Team today to put your mind at ease!