on 2021 Jan 05 6:22 AM
The error "CSRF token validation failed” is raised when you try to access an API via Postman.
You want to know how to resolve this error.
Request clarification before answering.
Hello Community,
In order to solve the error "CSRF token validation failed” you need to fetch the the CSRF token.
To do it, please follow the below steps:
1- Using GET go to Headers tab and add:
KEY = x-csrf-token VALUE = fetch
2- Press send.
3- The token will be generated at Header tab. Then you need copy the token and change for the field value "fetch".
Please refer to the image "CSRF" attached.
4- After that you will be able to use the POST method.
Hope it helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Changing the Default CSRF Protection Mechanism
To change the default CSRF protection mechanism, proceed as follows:
Go to transaction SICF.
Navigate to the ICF node for your service.
Double-click your service node.
On Service Data choose GUI Configuration.Caution
Enter the following values:
Parameter Name: ~CHECK_CSRF_TOKEN
Parameter Value: 0/1 (disable/enable)
Compatiblity Mode for SP02 - HTTP Handler in SICF (node sdata)
( Default : X-Requested-With, to enable XSRF check use, ~CHECK_CSRF_TOKEN=1)
The request handler is /IWFND/CL_SDATA_ODATA_APP.
Standard Mode - HTTP Handler in SICF (node odata)
( Default: XSRF check, to disable and switch to X-Requested-With, use ~CHECK_CSRF_TOKEN=0)
The request handler is /IWFND/CL_SODATA_HTTP_HANDLER.
Choose Continue and save your settings.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have also faced the same problem with our new S/4HANA System. I have disabled CSRF Token for a specific OData service in SICF by following the SAP Note.
https://me.sap.com/notes/2751277/en-US
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nice! Thank you for posting this solution
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am getting a error "CSRF token validation failed" using a Tcode: /n/IWFND/GW_CLIENT
Do you have any ideia to fix?
Thanks a lot
Rodolfo.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rodolfo,
could you please let me know how did you solve the error "CSRF token validation failed" in SAP Gateway?
i'm also facing the same error even though i have csrf-token in my post request. Your inputs will be very helpful.
Thanks
Vikram
| User | Count |
|---|---|
| 37 | |
| 23 | |
| 18 | |
| 6 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.