MikePR
MikePR

Reputation: 2986

GetStringAsync method in HttpClient throw an exception in WP8

Recently, I develop an App for WP8 and at the begining all worked OK. However, since yesterday nigth I was getting an error when trying to retrieve the RSS data from an url.

This is part of the code I use to get the data:

try
{
   HttpClient client = new HttpClient();
   var result = await client.GetStringAsync("http://www.scoop.it/t/recycling-by-miguel18/rss.xml");
   var parseResult = XDocument.Parse(result);
   . . .
}
catch (Exception ex)
{
   throw new Exception("Error: " + ex.Message);
}

Where source is the string which contain the url to get the RSS data. As commented, at the begining it was working OK, I was able to get the data in work with it.

Now, it raise the following error: Response status code does not indicate success: 404 ().

If I put the url directly to any browser I can see the RSS feeds. So, I don't undertand what would be wrong with the code. I am a little lost.

If you can help me to figure out what is wrong that would be very helpful

Regards!

Upvotes: 2

Views: 1905

Answers (3)

Yuri Dorokhov
Yuri Dorokhov

Reputation: 726

You need provide access to internet for your WP emulator.

This article can be helpful

connect WP emulator to internet

Upvotes: 2

Cabuxa.Mapache
Cabuxa.Mapache

Reputation: 771

Did you try adding an user-agent header? See DownloadString returns a 404 Error: Site needs a User-Agent Header.

Most webs blocks certain request to avoid robots. Try it and tell me please...

Upvotes: 0

Benyamin Maengkom
Benyamin Maengkom

Reputation: 139

hmm... I also get same error... using own class to call API, first call on navigatedTo success, second call using button click error, both using same code. On chrome rest client, the url success.

Upvotes: 0

Related Questions