How to consume http url for get/post in .net

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
i have one http url which I have to consume in .net but when I am cosuming it I am getting an error
The remote server returned an error: (401) Unauthorized
the url is given by some other user we have to get /post the data from the same

I m using this code
<span style="font-size:small <span style="font-size:small
string url =" http://dev.b2b.corporate.ge.com/xml/Outbound/GISCompute http://dev.b2b.corporate.ge.com/xml/Outbound/GISCompute ";<br/>
HttpWebRequest GETRequest = (HttpWebRequest)WebRequest.Create(url);<br/>
GETRequest.Method = "GET";<br/>
Console.WriteLine("Sending GET Request");<br/>
GETRequest.PreAuthenticate = true;
<br/>
string credentials = System.Convert.ToBase64String(Encoding.UTF8.GetBytes("com.geaute" + ":" + "com.ute"));<br/>
GETRequest.Headers.Add("Authorization", "Basic " + credentials);<br/>
HttpWebResponse GETResponse = (HttpWebResponse)GETRequest.GetResponse();<br/>
Stream GETResponseStream = GETResponse.GetResponseStream();<br/>
StreamReader sr = new StreamReader(GETResponseStream);<br/>
Console.WriteLine("Response from Server");<br/>
Console.WriteLine(sr.ReadToEnd());



<span style="font-size:small <span style="font-size:small
<span style="font-size:small <span style="font-size:small
could anyone provide some code snipt for the same or some modification on this
Please help
Thanks
Manoj

View the full article
 
Back
Top