cancel
Showing results for 
Search instead for 
Did you mean: 

IRPA2.0 Web Service Post - x-csrf-token

Muthu_Prabakara
Explorer
0 Kudos
779

Hi,

I have created IRPA bot to update the custom business object data via API through IRPA after business process execution. We have custom script that makes dummy call to the S4 HANA cloud API. From the error response, we will retrieve csrf token however after IRPA Core SDK update the below codes stopped working. Please suggest if you have any other alternative to retrieve csrf token to do post/patch operation to S4 API.

const options = { resolveBodyOnly: true, responseType: 'json', url: vURL, method: 'GET', headers: { 'x-csrf-token': 'fetch', 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': auth }};var token = '';try { const response = await irpa_core.request.call(options);} catch (error) { token = error.response.headers['x-csrf-token'];
}Thanks,Muthu
View Entire Topic
Jerry_Lowery
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Muthu,

If I remember correctly, the timeout is set to 30 minutes and I believe it is tied to the session timeout. Please check if you suspect there is a timeout issue.

I would recommend you look into the cause of why the token stops working.

One question that comes to mind is why you are only getting the token on error conditions?

Please be sure to also always log out after sending your message, or at least be sure that you are properly handling the sessions so they are never "left open". The system limits the number of open active sessions - this could be a cause of the failed messages if you reach the upper limit. (100)

Please see the note: 2760552 - Limitation of generation of HTTP security sessions

A couple of other interesting links:

(this is for successfactors, but still some good information): 2735876 - Odata API Best Practices [Query Modified Records, Pagination - Batch Size, Timeouts, etc.,...

https://answers.sap.com/questions/13244563/what-is-the-odata-api-timeout-on-s4hana-clould.html

App you may find helpful (Display Connectivity Trace)

https://help.sap.com/viewer/0f69f8fb28ac4bf48d2b57b9637e81fa/LATEST/en-US/a4f6ccd072f147f299b1d85606...

Thank you

Jerry

Muthu_Prabakara
Explorer

Issue here is different. I'm trying to call the S4 API in the IRPA bot using custom script. API call works fine. I have to perform an update operation for that I need CSRF token. Code used to get the token from error response based on the blog https://blogs.sap.com/2021/02/17/use-sap-analytics-cloud-rest-api-with-sap-intelligent-rpa-automatio...

TJe
Product and Topic Expert
Product and Topic Expert
0 Kudos

In the example from SAC, the reason why this is done with the error.response is just, that the request is searching for a SAC group which doesn't exist.
If your request works fine, you should get it directly from the response response.headers['x-csrf-token']; and of course not in the catch but directly after the await irpa_core.request.call().