on 02-02-2016 9:34 AM
Hi folks,
could you please advise me how to generate X-CSRF-Token with GET method. Service call is executed successfully with return code 200, but it is not returning CSRF Token, which I need in my front end for CRUD Operations.
Hi,
Try this code.
OData.request
({
requestUri: "Your Service Url",
method: "GET",
headers:
{
"X-Requested-With": "XMLHttpRequest",
"Content-Type": "application/atom+xml,application/json",
"DataServiceVersion": "2.0",
"X-CSRF-Token":"Fetch"
}
},
function (data, response)
{
header_xcsrf_token = response.headers['x-csrf-token'];
});
},
function(err)
{
sap.m.MessageToast.show("Token not received");
});
In header_xcsrf_token you will get the token value.
Regards,
Salu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try to add the GUI Parameter "~CHECK_CSRF_TOKEN" with the value "1" to OData service in Tx:"SICF", please check:
Cross-Site Request Forgery Protection
Best regards.
Hi,
I had the same problem, i found that the gateway client handled this value internally( try to put the header parameter "X-CSRF-Token" with the value "Fetch" on the gateway client, and you will see a popup with a warning),try to use a rest client tool like Postman to check the "X-CSRF-Token" value:
Best regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
92 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.