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();
Try removing these two lines from the request:
request.ContentType = "application/atom+xml";
request.Accept = "application/xml,application/atom+xml";
If I remember on the JavaScript side for WM 6.5, above two lines caused issues. I would imagine the same code is being used when you try to do the same thing from C#.
Hi,
Try Adding this additional header.
X-Requested-With : XMLHttpRequest
and check if it works.
Best Regards,
Sujith
Hi All,
i am develoing a native iOS application where I am trying to consume Odata services through Sybase Mobile Platform 2.3 and Relay server.
I have tested my Odata service url in rest client also and its working fine.
In my iOS code I am able to fetch the application end point but while fetching the service document I am getting this error SUPJsonException:expected string, found 173/Location:-[ODPRequest startSynchronous].
My code is
NSString *urlStr = [ODPAppSettings getApplicationEndpointWithError:&error];
NSURL *urlNew = [NSURL URLWithString:urlStr];
[SDMRequestBuilder enableXCSRF:YES];
id<SDMRequesting> request = [SDMRequestBuilder requestWithURL:urlNew];
[request setRequestMethod:@"GET"];
[request setUsername:@"xxxxxx"];
[request setPassword:@"xxxxxx"];
[request addRequestHeader:@"Content-Type" value:@"application/atom+xml;type=entry"];
[request addRequestHeader:@"X-Requested-With" value:@"XMLHttpRequest"];
[request startSynchronous];
My netweaver server version is 7.4. Could anyone please help me to resolve this issue.
With Regards
Neha Pandey
Hi Shine Gopal,
I'm also have same problem. System.Net.WebException: The remote server returned an error: (403) Forbidden. Could you please send your post request code so that I can refer.
And I didn't get about formatting cookie can you please elaborate because am new to this.
With Regards
Durai Venkatesh
Add a comment