The remote server returned an error: (401) Unauthorized

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello Everybody,
Im using this code to get XmlDocument from url: using (WebClient wc = new WebClient())
{
wc.Credentials = new NetworkCredential("admin", "admin");
string xml = wc.DownloadString("http://192.168.1.187:8550/epe/pos/taglist");

XmlDocument tournamentsXML = new XmlDocument();
tournamentsXML.LoadXml(xml);


XmlNodeList TagList = tournamentsXML.GetElementsByTagName("TAG");
foreach (XmlNode node in TagList)
{
XmlElement TagElement = (XmlElement)node;
string TagID = TagElement.GetElementsByTagName("tagid")[0].InnerText;
string MAC = TagElement.GetElementsByTagName("mac")[0].InnerText;
Data.Add(new Tag(TagID,MAC));
}
}
Its work fine,
But when I change the link to "http://192.168.1.187:8550/epe/pos/taglist?fields=posgood"
it give me error message "The remote server returned an error: (401) Unauthorized."
By the way when I copy past the same link "http://192.168.1.187:8550/epe/pos/taglist?fields=posgood" to browser it retreive XML data exactly !!
Please help me please :(
Belal

View the full article
 
Back
Top