cancel
Showing results for 
Search instead for 
Did you mean: 

Node.js code for HTTP POST with X-CSRF-Token

Former Member
0 Kudos

Hi all,

I am currently experimenting with a IoT solution. Instead of using the HCP, with the preconfigured IoT services, I have created an oData service on a HANA system on AWS.

To test the HTTP GET and the HTTP POST, I have used Postman, and it works. The HTTP POST via postman can be achieved by providing the X-CSRF-Token in the header data, which I have fetched first using a HTTP GET.

Now I am trying to replicate this with a Node.js javascript. However, after I have fetched the X-CSRF-Token with a HTTP GET, I want to do a HTTP POST with the actual data, and also with the X-CSRF-Token filled with the value i got from the fetch. However, the token value is not valid anymore when I create the POST request. I have tried to keep the session open, by using a http agent (keepAlive : true, maxSockets : 1), but with no success.

I also tried to turn off the X-CSRF-Token by changing the GUI parameters of my oData service in SICF by putting parameter ~CHECK_CSRF_TOKEN to 0, but also without success.

Does anyone know how this could be done with node.js?

Many thanks,

Steven Spronk

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

I'm facing the same issue right now, do you fix this issue now?

Former Member
0 Kudos

Are you sending the authentication cookie along your POST Request?