UiPath and SAP ByDesign Integration (x-csrf token) issue

Hello Experts.

I have encountered the x-csrf token issue. The token is extracted from SAP Bydesign to authenticate the SAP Bydesign. I can extract the token using http get method and this token can not use to authenticate. The token always changes when the UiPath program runs. I tested the SAP Bydesign API call using the Postman. The Postman works well but the UiPath Studio can not work. I used the uipath.web.activity in UiPath Studio to call the API services. Please let me know when you know the solution. Thanks.

Hi @Zaw_Win_Htun1,
Which activity have you tried to use for http call?

1 Like

I used the HTTP Request post method.

Hi @Zaw_Win_Htun1

Could you please provide more details? The side-by-side comparison of the original first call in Postman and UiPath settings would be helpful.

1 Like

Hi, Did you find a solution for this issue. I am also facing the same issue and trying since 5 days.

Hi @jegankumar.dp

Would you mind trying out sending your API calls to a service like https://webhook.site/ or https://pipedream.com/ to try and see the difference between the two API calls (one from UiPath HTTP Request activity and one presumably working one from Postman?
(or a local node.js service if you’d like of course)

This is usually the best place to start when one works and the other doesn’t

1 Like

hi bro,
i am facing the same problem right now, did you solve the problem,
it runs well on postman, but not work on uipath studio, it says “CSRF token validation failed”.
if you have any good idea, please let me know , thanks!

best wishs.
Seele.

@seele.yang @loginerror This is happening because of cookies issue I guess. I executed GET request in UiPath using http request to fetch csrf token and then made POST call with that token in postman, CSRF token failure error was thrown. Then I copied the cookies from GET request in UiPath and used those in postman and it worked. Now I tried to add cookies of GET request in POST request in UiPath but An item with the same key has already been added is being thrown. Any help is much appreciated.

Update: Hey guys. I read Set-Cookie header from GET request and added them in Cookies of POST request.

There are 2 cookies. One of them contains “=” and that’s why it didn’t work earlier. I replaced “=” with “%3D” and it’s working fine.

Refer the Name and Value of Cookies in Cookies tab of response in Postman and make sure you give the value of cookies in same format in Cookies of http request in UiPath.

Example of my case:

Header response of GET request in UiPath:

Set-Cookie - ABCD=25

I used ABCD=25 in Cookies of POST request in UiPath but it threw an error.

Checked the Cookie response of GET request in Postman. See below.

Name Value
Cookie. ABCD%3D25

I replaced “=” with “%3D” in UiPath and used ABCD%3D25 in Cookies of POST request in UiPath and it worked.

If this helps you, please mark it as solution. Thanks guys.

1 Like