Warm tip: This article is reproduced from serverfault.com, please click

How do I set the X-CSRF-Token correctly in an Alexa POST Request to SAP HANA? (403 error)

发布于 2017-12-19 19:46:08

I have a problem with the x-csrf-token validation with regard to a HTTPS-Post-Request. The request comes from a Lambda function triggered by an Amazon Alexa skill and is sent to a XSO Data file running on the SAP Cloud Platform in an SAP HANA Database. I use Javascript/Node.js.

A valid token is set in the request header (see code in the first picture below) but the response header shows for the x-csrf-token "required" (see code in the second picture below). So there is an error with the validation. The same post request with POSTMAN works correctly, but when I try it via a JS File as a Lambda function (in the first picture) there it comes this error with HTTP status code 403 (see code in the second picture below). The POST request itself does work, but the token validation not. GET requests work fine.

Does anybody know a possible solution?

Thank you very much!

1.picture: request

2.picture: response

Questioner
VfBPower123
Viewed
0
Saswata Roy 2018-01-16 04:47:39

Please try to get the csrf token first before setting it to the request body. CSRF token changes from device to device as well as the timeframe. I also had a similar issue, and upon implementing the above solution, it started working perfectly.