Skip to Content

Getting 403 Error while trying to POST data into SAP

Jul 24, 2017 at 09:54 AM


avatar image
Former Member

Am trying to POST data into SAP Net weaver 7.4 Version from SharePoint page using oData service from SAP. I am getting 200 OK message when I try from Google ARC but continue getting 403 error while trying from C# code. Below is my code snippet.

string _username = "uname";

string _password = "psw";

string setCookie = String.Empty;

CookieContainer cookieJar = new CookieContainer();

var GetURI = "'2345',Lang='e')?sap-client=300";

var syncClient = new WebClient();

syncClient.Headers.Add("X-CSRF-Token", "Fetch");

syncClient.Credentials = new NetworkCredential("username", "psw");

var content = syncClient.DownloadString(GetURI);

string _Token = syncClient.ResponseHeaders["X-CSRF-Token"].ToString();

string cokie = syncClient.ResponseHeaders["Set-Cookie"].ToString();

/* POST Section */ string

PostURI = ""; syncClient.Headers.Add("Authorization", "Basic RTAwMjQzNzE6YXByaWxAMjAxNw==");

syncClient.Headers.Add("Content-Type", "application/atom+xml"); syncClient.Headers.Add("X-CSRF-Token", _Token);

syncClient.Headers.Add("Set-Cookie", cokie);

syncClient.Credentials = new NetworkCredential(_username, _password); syncClient.UploadString(PostURI, content);

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

avatar image
Former Member Jul 25, 2017 at 03:51 AM

Hi Samh,

What is the port in the uri :

Is it (8000) backend http port ?

check if this port is accessible and it is activated.

Manjunath Hanmantgad

10 |10000 characters needed characters left characters exceeded