cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CSRF token validation failed for my POST Method in SAPUI5 using Eclipse?

vamsilakshman_pendurti
Active Participant
0 Likes
14,766

Hi Experts,

Here i am facing one issue with Create an entry into Database Table using SAPUI5 & OData. Fetching the data from Database and displaying in our SAPUI5 application has been done perfectly using OData Service. Fetching purpose i used the below code...

Output:

when i was trying to create by clicking on Create button : below i am providing my code for Create (POST) Method...

when i click on Save button it will not triggering my jQuery.ajax line in my Controller code so that it displays else part message.

In DOM i got the error like CSRF token validation failed...

i searched in SCN with the above mentioned error wise, but no relevant solution is found. If any one face this kind of issue and resolved please guide me the steps...where exactly i did the mistake.

Thanks,

Vamsi.

View Entire Topic
gaurav_setu
Explorer
0 Likes

csrfToken : function(th){ var that=this; var a = "any entity set url or service url"; var f = { headers : { "X-Requested-With" : "XMLHttpRequest", "Content-Type" : "application/atom+xml", DataServiceVersion : "2.0", "X-CSRF-Token" : "Fetch" }, requestUri : a, method : "GET" }; OData.request(f, function(data, oSuccess) { this.ViewThis.oToken = oSuccess.headers['x-csrf-token']; }); },