hi,
I would like to send data to my REST Service provider. If I only receive data everything works ok but when I send data I got error: The request was aborted: The request was canceled
I tried sent data in Content-Type: text/json or text/html. I always got above error.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(subscriptionAdd);
string postData = "email=test%40test.pl&subject=test+emaila"; //for text/html
postData = "{subscriber:test@test.pl}"; //for text/json
request.ContentLength = postData.Lenght;
string sha1String = APIKey + "/rest/subscriber/add" + postData + APISecret;
string XRestApiSign = SHA1HashStringForUTF8String(sha1String);
request.Method = WebRequestMethods.Http.Post;
request.ContentType = "text/json";
request.Headers.Add("X-Rest-ApiSign", XRestApiSign);
request.Headers.Add("X-Rest-ApiKey", APIKey);
request.ContentLength = postData.Length;
StreamWriter requestWriter;
Stream webStream = request.GetRequestStream();
requestWriter = new StreamWriter(webStream, System.Text.Encoding.UTF8);
requestWriter.Write(postData);
requestWriter.Close();
Do you see any bug in code?
I tried send data like byte[] then I don't get error but my service provider return 401 unathorized. Maybe I wrong but data in byte[] type isn't
identical to json or html content type..
Best regards Jacek