The code itself isn’t complex, it’s just not working properly:
Uri uri = new Uri("https://www.google.com/webmasters/tools/feeds/sites/http%3A%2F%2Fwww.mydomain.co.uk%2F");
WebRequest.Create(uri);
I get a “Bad Request” back from the server, and after much MUCH digging, discovered that the Uri is being turned into
https://www.google.com/webmasters/tools/feeds/sites/http%3A//www.mydomain.co.uk/
which is not what I asked for, and so it’s having a whinge
Is there a way to stop this?
Answer found here: https://stackoverflow.com/a/10415482/159341
According to the bug report for this issue on Microsoft Connect, this behaviour is by design, but you can work around it by adding the following to your app.config or web.config file:
(Since WebRequest.Create(string) just delegates to WebRequest.Create(Uri), you would need to use this workaround no matter which method you call.)