Skip to Content
0
Former Member
Jun 24, 2013 at 10:50 AM

OData POST request returning 403 forbidden

5926 Views

Hi All,

I am trying to make a POST request from windows mobile 6.5 through SUP; I have included the headers X-CSRF-Token and X-SUP-APPCID. Please help me to correct the error in my code.

HttpWebRequest request =

(HttpWebRequest)HttpWebRequest.Create(url);

request.Credentials = cache;

request.Method = "POST";

request.ContentType = "application/atom+xml";

request.Accept = "application/xml,application/atom+xml";

request.AllowWriteStreamBuffering = true;

request.Headers.Add("X-SUP-SC", "Security1");

request.Headers.Add("X-CSRF-Token", XCSRFToken);

request.Headers.Add("X-SUP-APPCID", ApplicationConnectionID);

request.Headers.Add("X-SUP-URLREWRITE-ENABLED", "False");

request.Headers.Add("Set-Cookie", strCookie);

byte[] bytes = Encoding.UTF8.GetBytes(postData);

request.ContentLength = bytes.Length;

using (Stream putStream = request.GetRequestStream())

{

putStream.Write(bytes, 0, bytes.Length);

putStream.Close();

}

` WebResponse response = request.GetResponse();