cancel
Showing results for 
Search instead for 
Did you mean: 

POST to C4C returns 403 "CSRF token validation failed" despite valid token

Former Member
0 Kudos

First I tested that my POST to C4C would work from a browser rest client, to ensure the backend service is working correctly:


Then I created an OData model in SAPUI5 (in the console), pointing to my C4C OData service, and refresh the security token.  I check that the CSRF-Token has been retrieved:

I now attempt to create (POST) the data in the console:

this fails, with error around the CSRF token (example below, should match CSRF token above, but was taken from a different attempt):

Has anyone experienced this before? nomatter how often i refresh the CSRF token it fails..but I think the error text might be wrong, as there is no reason why the token is not working...

Thank you in advance for any help.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Lindsay,

It could be because in your REST client you are calling the proper service which is HTTPS, and then in your localhost proxy server it is only HTTP.

Thanks

John

Former Member
0 Kudos

John, you're a star! This was exactly the reason

For others: I reattempted this test, by running my localhost on https (https://localhost:443) and this now works!

I have since testing this on HCP (HANA Cloud Platform) and it works perfectly (HCP is on HTTPS already)

Thank you John!

Answers (1)

Answers (1)

kedarT
Active Contributor
0 Kudos

Hi Lindsay,

I hope you have two way binding enabled for the model as below:

oModel.setDefaultBindingMode(sap.ui.model.BindingMode.TwoWay);

Also you have put in the binding syntax  to complex in index.html

data-sap.ui.xx-bindingSyntax="complex"

Hope this helps.

Former Member
0 Kudos

Thank you for your suggestions, I have tried these:

Sadly it failed, even though the binding is two way, and in my index I have it set to "complex" and the CSRF token is set: