I have a REST service in JAVA that I need to call by using POST.
Following is my call from .Net -
string postData = "version=2.1&serviceName=createToken";
string endPoint = https://devservices.caremark.com:450/onesite/oneSiteToken/createToken + "?" + postData;
// create endpoint var request = (HttpWebRequest)WebRequest.Create(endPoint);//WebRequest request = WebRequest.Create(endPoint);request.Method = "POST";byte[] postDataBytes = Encoding.UTF8.GetBytes(postData);request.ContentType = "application/x-www-form-urlencoded";request.ContentLength = postDataBytes.Length; var dataStream = request.GetRequestStream(); //this is where it erring out: NotSupported ExceptiondataStream.Write(postDataBytes, 0, postDataBytes.Length);dataStream.Close();
var response = (HttpWebResponse)request.GetResponse(); //this comes out null
Can someone please tell me what I am doing wrong or suggest me an alternative way to to this. I am really stuck at this one :(
Thanks!