private static string CallRestMethod(string url)
{
var webrequest = (HttpWebRequest)WebRequest.Create(url);
webrequest.Method = "GET";
webrequest.ContentType = "application/x-www-form-urlencoded";
webrequest.Headers.Add("Username", "xyz");
webrequest.Headers.Add("Password", "abc");
var webresponse = (HttpWebResponse)webrequest.GetResponse();
Encoding enc = Encoding.GetEncoding("utf-8");
var responseStream = new StreamReader(webresponse.GetResponseStream(), enc);
string result = responseStream.ReadToEnd();
webresponse.Close();
return result;
}
Comments
Post a Comment