Forum Discussion

justmehere's avatar
justmehere
Frequent Visitor
1 year ago
Solved

REST API Authentication Issue in Microsoft Fabric Pipeline - 401 Unauthorized

Issue Description:
I'm trying to integrate Acumatica ERP with Microsoft Fabric using the REST API.

1. Initial Login (Web Activity) works successfully:
URL: https://{MYBASEURL}/entity/auth/login
Method: POST
Headers:
- Accept: application/json
- Content-Type: application/json
Body:
{
"name": "[username]",
"password": "[password]"
}

The login returns successful with cookies in ResponseHeaders['Set-Cookie'].

2. Subsequent Copy Activity fails with 401 Unauthorized:
When trying to access: https://[MYBASEURL]/entity/Default/20.200.001/Customer

I've tried passing the authentication cookie from the login response:
Headers:
- Accept: application/json
- Content-Type: application/json
- Cookie: @{activity('Web_Activity_Login_Testing_1').output.ResponseHeaders['Set-Cookie']}

Error received:
"ErrorCode=RestCallFailedWithClientError,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Rest call failed with client error, status code 401 Unauthorized, please check your activity settings."

Questions:
1. What is the correct way to pass authentication from the login response to subsequent API calls in Microsoft Fabric?
2. Is there a recommended approach for maintaining session/authentication when using Acumatica REST API with Microsoft Fabric pipelines?
3. Are there any specific header requirements I'm missing?

Full login response for reference is below:
{ "Response": "", "ResponseHeaders": { "Cache-Control": "private", "Set-Cookie": "ASP.NET_SessionId=XXXXX; path=/; HttpOnly; SameSite=Lax;UserBranch=1; path=/;Locale=Culture=en-US&TimeZone=GMTM0700A; expires=Thu, 31-Oct-2024 05:40:05 GMT; path=/;.ASPXAUTH=XXXXX; path=/; secure; HttpOnly; SameSite=None;ASP.NET_SessionId=XXXXX; path=/; HttpOnly; SameSite=Lax;UserBranch=1; path=/;Locale=Culture=en-US&TimeZone=GMTM0700A; expires=Thu, 31-Oct-2024 05:40:05 GMT; path=/;.ASPXAUTH=XXXXX; path=/; secure; HttpOnly; SameSite=None;requestid=XXXXX; path=/;requeststat=+st:118+sc:~/entity/auth/login+start:638656908055761270+tg:; path=/", "Date": "Mon, 28 Oct 2024 05:40:05 GMT" }, "executionDuration": 4

 



7 Replies

  • Hi,

     

    Are you able to get it working in another client like postman?

    • justmehere's avatar
      justmehere
      Frequent Visitor

      Yes I am able to get it working on postman

      • FabianSchut's avatar
        FabianSchut
        Icon for Solution Sage rankSolution Sage

        I think the error is in the cookie statement: @{activity('Web_Activity_Login_Testing_1').output.ResponseHeaders['Set-Cookie']}. Can you show the output of the web activity? You can blur the sensitive information.