Skip to Content

csrf token validation failed while using post method for c4c custom object in absl code

Hi Expert,

I am using post method to create a record in the c4c custom object but it is throwing csrf token validation failed error 403 . As suggested in other blogs i have used the get method and retrieved the csrf token and other parameter but not able to create record.

Can anyone can help me with this issue?

Thanks in advance.

Regards,

Abhishek

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Feb 20 at 05:59 AM

    Hi Abhishek,

    Even If you are passing the CSRF token in POST method which you got from GET request, C4C may understand that this GET and POST HTTPS requests originates from different client sessions so your CSRF token validation may fail when you implement it through your custom code.

    Basically HTTP is a stateless protocol, to maintain the state between 2 HTTP requests you can use the cookies method.

    Server cookies returned in GET request (as shown in attached Image) can be used to maintain the state in the subsequent POST request, then you can avoid the CSRF validation failure.

    Regards,

    Vignesh

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Vignesh,

      Thanks for your response.

      I tried to implement the same (fetch the cookie and csrf token value from the get method and set it to the post method) but it didn't work.

      It is working using the postman tool but the same when I am trying to implement using the ABSL code it doesn't work.

      Have you tried to post any data to the odata service of C4C?

      Please let me know if you find anything ...

      Regards,

      Abhishek

  • Feb 19 at 09:00 AM

    Hi,

    I am also getting the same error when trying to post data using C4C odata REST service.

    Regards,

    Ambuja

    Add comment
    10|10000 characters needed characters exceeded