Skip to Content
1
Jan 13, 2022 at 03:36 PM

How to get a x-csrf-token from on-prem System for a POST API

724 Views Last edit Jan 13, 2022 at 03:37 PM 2 rev

Hi all,

just now the POST call of my API from the API Management is not working, because of the X-CSRF-TOKEN. I want to use the API to add data into a database table. Behind the API is an O-Data service.

My first step was to create an API provider with the target on prem system. This works without problems and I used it when I was creating my API.

The next step was to create my REST-API with the desired O-Data service. After I created the API, I created some policies. These are based on the following article: https://blogs.sap.com/2021/09/18/csrf-token-handling-in-sap-api-management/

And my service callout policy looks like this:

image.png

As a path, I use the API Base Path from the same API:

image.png

The GET-Request works fine and gives me Data from the Database.

The POST-Request sends the error: "{

"fault":{
"faultstring":"Unresolved variable : servicecallOutResponse.header.x-csrf-token",
"detail":{
"errorcode":"entities.UnresolvedVariable"
}
}
}"

The HTTP-Error Code is 500.

Unfortunately I don't know why this behavior occurs so feel free to answer.

Best regards,

Max

Attachments

image.png (19.6 kB)
image.png (19.3 kB)