Hi,
I am creating a WCF rest service to consume SAP OData service in my application i am able to read data but not able to insert entity.
I am getting an issue while add X-CSRF-Token to Entity Request Header. Please help me on this.
var cookieContainer = new CookieContainer();
cookieContainer.Add(new Cookie("SAP_SESSIONID", "value"){Domain= Uri.Host});
var entities = new ServiceReference1.leaverequest_Entities(sapUri);
entities.Credentials = new NetworkCredential("username", "password");
entities.SendingRequest += (s, e) =>
{
((HttpWebRequest)e.Request).CookieContainer = cookieContainer;
((HttpWebRequest)e.Request).Headers.Add("X-CSRF-Token", csrfToken);
};
entities.AddToLeaveRequestCollection(leaveRequest);
entities.SaveChanges();
I wrote unit test for debug my POST implementation. When i am debugging the code , when ever "((HttpWebRequest)e.Request).Headers.Add("X-CSRF-Token", csrfToken)" code executing , i am getting exception that "csrf token validation failed".
Need a help on this Urgent?
Thanks,
Siva