Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var values = new NameValueCollection();
- values["clientId"] = clientId;
- values["clientIP"] = currentIP;
- byte[] response;
- var resultResponse = string.Empty;
- using (var client = new WebClient())
- {
- try {
- response = client.UploadValues(url, values);
- resultResponse = Encoding.Default.GetString(response);
- }
- catch (WebException e)
- {
- string exception = string.Empty;
- if (e.Status == WebExceptionStatus.ProtocolError)
- {
- exception += ((HttpWebResponse)e.Response).StatusCode;
- exception += ((HttpWebResponse)e.Response).StatusDescription;
- }
- }
- }
- string method = "post";
- WebRequest req = WebRequest.Create(uri);
- req.ContentType = contentType;
- req.Method = method;
- req.Headers.Add("myhead", value);
- req.ContentLength = jsonDataBytes.Length;
- var stream = req.GetRequestStream();
- stream.Write(jsonDataBytes, 0, jsonDataBytes.Length);
- stream.Close();
- var response = req.GetResponse().GetResponseStream();
- StreamReader reader = new StreamReader(response);
- var res = reader.ReadToEnd();
- reader.Close();
- response.Close();
- return res;
Add Comment
Please, Sign In to add comment