When trying to use Delicious API to get users bookmarks I get WebException saying "The remote server returned an error: NotFound.". I have looked and I can't find any more details about the problem.
Here is the code that I am using. Do someone know what can be wrong?
string fullUrl = "https://api.del.icio.us/v1/posts/al开发者_运维技巧l?";
WebClient client = new WebClient();
client.Credentials = new System.Net.NetworkCredential(Username, Password);
client.Headers[HttpRequestHeader.UserAgent] = "DeliciousWindowsPhoneClient";
client.DownloadStringAsync(new Uri(fullUrl));
client.DownloadStringCompleted += (object sender, DownloadStringCompletedEventArgs e) => {
if (e.Error == null)
{
XDocument xmlDocument = XDocument.Parse(e.Result);
callback(new DownloadXmlCompletedArgs(e) { Xml = xmlDocument });
}
else
{
callback(new DownloadXmlCompletedArgs(e));
}
lastConnectTime = System.DateTime.Now;
};
It is the server responding with an error, not found. Have you double-checked the URL ? Try visiting it in a browser.
If the browser works, and the code does not, try narrowing down the differences between the requests being sent. Perhaps the server requires a specific header or a cookie to allow you access ? A good tool for narrowing this down is Fiddler.
精彩评论