on 05-04-2021 12:49 PM
Hello
I have managed to build a local workspace in VSCode and it works really good so far.
Now I have only one Problem: When I try to make a POST request via oDataModel to the SAP Backend, I get the following error:
CSRF token validation failed
I have searched in server blogs and found out, that in normal scenario it is required to first fetch the CSRF token and then add it in the POST request.
But since i am working with the oDataModel.v2 from firoi, the whole token handling is already made by this class.
I also see in the browser network protocol, that it makes first the fetch and after that the POST request.
But I still receive the same error.
Here is how I instantate my oDataModel:
getServiceModel: function (serviceName, _defaultUpdateMethod) {
return new ODataModel("https://myserver.company.com:port/sap../Z_SRV", {
defaultOperationMode: sap.ui.model.odata.OperationMode.Server,
defaultBindingMode: sap.ui.model.BindingMode.OneWay,
defaultCountMode: sap.ui.model.odata.CountMode.Request,
defaultUpdateMethod: sap.ui.model.odata.UpdateMethod.Merge,
earlyTokenRequest: true,
tokenHandling: true,
serviceUrlParams: {
"sap-client": "200"
}
});
}
Does anyone have any idea what the problem could be?
Thanks
Regards
Osman
Hi guys
The problem is solved now, it turned out that I had to set the parameter tokenHandling, to false. After that I was able to fetch data from the oDataService.
new ODataModel(this.sBaseUrl + serviceName + "/", {
tokenHandling: false
});
Thanks again
Regards
Osman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
try oDatamodel.refreshSecurityToken() once before your POST request, it might help, or delete below two properties from your model definition, default value would be ok i.e. earlyTokenRequest is 'false' and tokenHandling is 'true'.
earlyTokenRequest: true,
tokenHandling: true,
Thanks,
Akhilesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
11 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.