Tim Rodman
Tim Rodman

Reputation: 66

Using Acumatica REST API with Microsoft Flow

Has anyone tried using the Acumatica REST APIs with Microsoft Flow?

I tried it a few weeks ago using Sergey's instructions (click here) and it worked fine.

But now I'm getting the following message on the second step.

{ "message": "You are not logged in." }

The first step is where I authenticate (just like in Sergey's instructions), then I pass the headers from the first step to the second step (just like in Sergey's instructions), but somehow the second step doesn't think that I'm logged in.

Any ideas?

Here are some screenshots (the only thing I changed for the screenshot is the password):

Here are the Headers Outputs from the first call (HTTP): X-Handled-By Acumatica-PX.Export/AuthenticationManagerModule Set-Cookie ASP.NET_SessionId=0koh1ysshqsfmzr0srib2s5z; path=/; HttpOnly,UserBranch=16; path=/,Locale=Culture=en-US&TimeZone=GMTM0800A; expires=Sat, 18-Nov-2017 17:51:27 GMT; path=/,.ASPXAUTH=880C71F4E1A76C36E7E468337C01BC9E6E4C898E1977BAAAF2A35F7217B1D9132794A9547071508A35A2D4B9132DC4B55E86DD6E9C9B8D46CAECE39D74CC9B44BDD47E7C0D836D22D8F4EEFAF8142A9987418B8003EFF5B340DF735E7F8F36EDE5D25300D887E4DADEB0A80B707D87F6B0D32437; path=/; HttpOnly Server Microsoft-IIS/7.5 X-Powered-By ASP.NET Date Wed, 15 Nov 2017 17:51:27 GMT Content-Length 0

Here are the Headers Inputs from the second call (HTTP 2): { "X-Handled-By": "Acumatica-PX.Export/AuthenticationManagerModule", "Set-Cookie": "ASP.NET_SessionId=0koh1ysshqsfmzr0srib2s5z; path=/; HttpOnly,UserBranch=16; path=/,Locale=Culture=en-US&TimeZone=GMTM0800A; expires=Sat, 18-Nov-2017 17:51:27 GMT; path=/,.ASPXAUTH=880C71F4E1A76C36E7E468337C01BC9E6E4C898E1977BAAAF2A35F7217B1D9132794A9547071508A35A2D4B9132DC4B55E86DD6E9C9B8D46CAECE39D74CC9B44BDD47E7C0D836D22D8F4EEFAF8142A9987418B8003EFF5B340DF735E7F8F36EDE5D25300D887E4DADEB0A80B707D87F6B0D32437; path=/; HttpOnly", "Server": "Microsoft-IIS/7.5", "X-Powered-By": "ASP.NET", "Date": "Wed, 15 Nov 2017 17:51:27 GMT", "Content-Length": "0" }

Here are the Headers Outputs from the second call (HTTP 2): X-Handled-By Acumatica-PX.Export/AuthenticationManagerModule Date Wed, 15 Nov 2017 17:51:27 GMT Set-Cookie ASP.NET_SessionId=dklemj2usv2zveyc3acxnhm5; path=/; HttpOnly Server Microsoft-IIS/7.5 X-Powered-By ASP.NET Content-Length 36 Content-Type application/json; charset=utf-8

Upvotes: 0

Views: 1358

Answers (1)

samol518
samol518

Reputation: 1404

I had one previously and the difference that I see between your and mine is that your login post doesn't have any headers.

Mine had :

Accept application/json

Content-Type application/json

Here is a screenshot of my working flow : https://i.sstatic.net/vRVny.jpg

EDIT :

After playing with this a bit more I have found a way off making this work. though it is using OAuth authentication instead of cookie based authentication. Here is how :

  1. I first created a connected application on the screen of the same name in acumatica
    • Of the following type : Ressource Owner Password Credentials
    • I also created added a shared secret while taking note of its value (it is only showed once).

  1. I created the first http call in flow using the following information
    • URL : https://"Acumatica ERP instance URL"/identity/connect/token
    • Header : Content type / application/x-www-form-urlencoded
    • Body : grant_type=password&client_id=Value1&client_secret=Value2&username=Value3&password=Value4&scope=api

Value1 : ID of the connected application created in step 1

Value2 :Value of the shared secret saved from step 1. If lost just remove and add another secret. just be careful no one else is using that secret

Value3 : Username of existing account

Value4 : Password of account specified in value 3


  1. Create the second HTTP call that will do the web service request
    • URL : https://"Acumatica ERP instance URL"/entity/Default/17.200.001/Case
    • Header : Authorization / bearer substring(substring(string(body('HTTP_2')),indexOf(string(body('HTTP_2')),':'),34),2,32)
    • Body : a normal REST API body for the requested operation

The Substring is only separated by a space in the header


Here are image representing the 2 HTTP calls First HTTP call in Flow Second HTTP call in Flow

Upvotes: 1

Related Questions