The remote server returned an error: (407) Proxy Authentication Required.
// Restful service URL string url = @"https://url/url"; var filePath = @"..\PostXML.xml"; ASCIIEncoding encoding = new ASCIIEncoding(); string strResult = string.Empty; string SampleXml = File.ReadAllText(filePath); string postData = SampleXml.ToString(); byte[] data = encoding.GetBytes(postData); HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(url); webrequest.Method = "POST"; webrequest.ContentType = "application/soap+xml"; webrequest.ContentLength = data.Length; webrequest.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes("username:password")); webrequest.Headers.Add("Client-Id", "2345678igfdfguio"); webrequest.Headers.Add("Client-Secret", "490iugfghjki-ltyhjvb"); Stream newStream = webrequest.GetRequestStream(); newStream.Write(data, 0, data.Length); newStream.Close(); HttpWebResponse webresponse = (HttpWebResponse)webrequest.GetResponse(); Encoding enc = System.Text.Encoding.GetEncoding("utf-8"); StreamReader loResponseStream = new StreamReader(webresponse.GetResponseStream(), enc); strResult = loResponseStream.ReadToEnd(); loResponseStream.Close(); webresponse.Close(); strResult = strResult.Replace("</string>", ""); Console.Write(strResult);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)