seldary
seldary

Reputation: 6256

Webmaster Tools API C# - Url Encoded SiteID causing 400 response

The Webmaster Tools API requires a SiteID for most operations.
This SiteID is a Url Encoded version of the site's url, as appears in the Google Webmaster Tools dashboard.

So why does the next URL doesn't work (the dreaded "Bad Request", or "Site Not Found")?

var site = "http://example.com/";
var urlEncoded = HttpUtility.UrlEncode(site);
var url = "https://www.google.com/webmasters/tools/feeds/" + urlEncoded + "/crawlissues/";

Upvotes: 1

Views: 540

Answers (1)

seldary
seldary

Reputation: 6256

Google expects upper case letters for the encoded characters, while HttpUtility.UrlEncode produces lower case characters.

See this answer for a "selective ToUpper" method implementation.

(Another thing, the last slash might make a difference! http://x.com/ is not http://x.com)

Upvotes: 1

Related Questions