I am trying to consume a REST service from another company. When I use the link in the browser it works fine. However I get the 401 error when accessing from code. What am I doing wrong? Do I need to add something to the web.config of the web app?
string URL = @"https://hdapps-qa.homedepot.com/MYTHDPassport/rs/identity/isSessionValid?thdsso=TEST&callingProgram=PSC&Submit=Submit";
HttpWebRequest req = WebRequest.Create(URL)
as HttpWebRequest;
string result = null;
req.Method = "GET";
req.UseDefaultCredentials = true;
req.PreAuthenticate = false;
req.Credentials = CredentialCache.DefaultCredentials;
using (HttpWebResponse resp = req.GetResponse()
as HttpWebResponse)
{
StreamReader reader =
new StreamReader(resp.GetResponseStream());
result = reader.ReadToEnd();
}