Forum Discussion
REST API Authentication Issue in Microsoft Fabric Pipeline - 401 Unauthorized
- 1 year ago
You are getting the cookie correct indeed. However, I can see that ADF did not support setting a cookie in a copy activity: https://learn.microsoft.com/en-us/answers/questions/1292520/how-to-add-cookie-header-in-adf-copy-activity. I think Fabric does not support it either. I think you need to set up antoher authentication at the Acumatica ERP side. I found some blogs that might help: https://help.acumatica.com/(W(5))/Help?ScreenId=ShowWiki&pageid=a8f71c44-9f5c-4af8-9d47-bc815c8a58e7
https://docs.celigo.com/hc/en-us/articles/360047399452-Set-up-an-OAuth-2-0-connection-to-Acumatica#set-up-an-oauth-2-0-connection-to-acumatica-0
This is the output from the web activity with sensitive info blurred:
{ "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
You are getting the cookie correct indeed. However, I can see that ADF did not support setting a cookie in a copy activity: https://learn.microsoft.com/en-us/answers/questions/1292520/how-to-add-cookie-header-in-adf-copy-activity. I think Fabric does not support it either. I think you need to set up antoher authentication at the Acumatica ERP side. I found some blogs that might help: https://help.acumatica.com/(W(5))/Help?ScreenId=ShowWiki&pageid=a8f71c44-9f5c-4af8-9d47-bc815c8a58e7
https://docs.celigo.com/hc/en-us/articles/360047399452-Set-up-an-OAuth-2-0-connection-to-Acumatica#set-up-an-oauth-2-0-connection-to-acumatica-0
- justmehere1 year agoFrequent Visitor
Thank you so much. I opted to use the Notebook activity and wrote the python code below and I can pull the data. Thank you, this has saved me lots of time:
Attaching the python code for anyone in future:import requestsimport json# Login to Acumaticadef login_to_acumatica():login_url = "https://{YOUR_BASE_URL}/entity/auth/login"headers = {"Accept": "application/json","Content-Type": "application/json"}login_data = {"name": "XXXXX","password": "XXXXX"}session = requests.Session()response = session.post(login_url, headers=headers, json=login_data)return session, response.cookies# Get Datadef get_customer_data(session, cookies😞customer_url = "https://{YOUR_BASE_URL}/entity/{API_VERSION}/{}/Customer"headers = {"Accept": "application/json","Content-Type": "application/json"}response = session.get(customer_url, headers=headers, cookies=cookies)return response.json()# Main executionsession, cookies = login_to_acumatica()customer_data = get_customer_data(session, cookies)customer_data