string url = "https://rest.na1.netsuite.com/app/site/hosting/restlet.nl?script=108&deploy=1";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.ContentType = "application/json";
request.Method = "GET";
request.Headers.Add("Authorization:NLAuth nlauth_account=1234567,nlauth_email=email@netsuite.com,nlauth_signature=password,nlauth_role=3");
//create a cookie container to handle cookies sent by NetSuite
request.CookieContainer = new CookieContainer();
WebResponse response = request.GetResponse();
HttpWebResponse httpResponse = (HttpWebResponse)response;
//send subsequent request
HttpWebRequest subsequentRequest = (HttpWebRequest)WebRequest.Create(url);
subsequentRequest.ContentType = "application/json";
subsequentRequest.Method = "GET";
//create cookie container as placeholder for cookie from initial request
subsequentRequest.CookieContainer = new CookieContainer();
//add cookie to the cookiecontainer of the subsequent request
subsequentRequest.CookieContainer.Add(httpResponse.Cookies["JSESSIONID"]);
WebResponse subsequentResponse = subsequentRequest.GetResponse();
HttpWebResponse subsequentHttpResponse = (HttpWebResponse)subsequentResponse;
Friday, January 4, 2019
Sample C# code on sending RESTlet requests using JSESSIONID for Authentication
Sample C# code on sending RESTlet requests using JSESSIONID for Authentication
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment