cancel
Showing results for 
Search instead for 
Did you mean: 

Getting 403 Error while trying to POST data into SAP

Former Member
0 Kudos

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 = "http://vdderc.server.gov.ae:8000/sap/ewe/odata/sap/ZHR_IAWARD_APP_SRV/AppEntitySet(Pernr='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 = "http://vdderc.server.gov.ae:8000/sap/ewe/odata/sap/ZHR_IAWARD_APP_SRV/AppEntitySet?sap-client=300"; 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);

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Hi Samh,

What is the port in the uri : http://vdderc.server.gov.ae:8000

Is it (8000) backend http port ?

check if this port is accessible and it is activated.

Regards,
Manjunath Hanmantgad