TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
mauve beads
NA
3
1.8k
401 rest service: works in browser, error from code
Dec 3 2013 4:48 PM
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();
}
Reply
Answers (
1
)
Hosting WCF In WAS
WCF and WSDL