geremyk / google-gdata

Automatically exported from code.google.com/p/google-gdata
0 stars 0 forks source link

Google Webmaster Tools API is not working with .NET client library #183

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Retrieve site's registered sitemaps feeds with Google Webmaster Tools API.
2. Do AuthStub authentification (omit here)
3. Use for example this hypotetic url -
https://www.google.com/webmasters/tools/feeds/http%3A%2F%2Fwww%2Eexample%2Ecom%2
F/sitemaps/

What is the expected output? What do you see instead?
Requested feed.
I get 400 Bad request error, because .NET Uri class always unescape escaped
direct slash (%2f) and dot (%2e) from url. So it sends request to
https://www.google.com/webmasters/tools/feeds/http%3A//www.example.com//sitemaps
/

Original issue reported on code.google.com by derigel on 26 Oct 2008 at 2:37

GoogleCodeExporter commented 8 years ago
There is nothing i can do to work around this beside recommend using mono (it 
works fine under mono). That is 
a security issue (as claimed by Microsoft) and beside replacing the URI class, 
i don't see a solution to the 
problem. 

You could file this bug as a bug against the service and ask them to change the 
scheme (make it a parameter for 
example). 

Original comment by fman...@gmail.com on 27 Oct 2008 at 9:40

GoogleCodeExporter commented 8 years ago
Double encode the uri:

SiteUri = "http://example.com"
SiteFeedUriTemplate = "https://www.google.com/webmasters/tools/feeds/sites/{0}"
Server = System.Web.HttpContext.Current.Server

Encoded = Server.UrlEncode(SiteUri)
DoubleEncoded = Server.UrlEncode(Encoded)

FeedUri = String.Format(SiteFeedUriTemplate, DoubleEncoded)

Original comment by langs...@gmail.com on 13 Nov 2008 at 2:10

GoogleCodeExporter commented 8 years ago
Thank you for posting the DoubleEncode solution. Worked and worked and worked 
on 
that one.

Original comment by rpa.ad...@gmail.com on 6 Feb 2009 at 5:03

GoogleCodeExporter commented 8 years ago
Your sample wouldn't work without the trailing "/" at the end of the SiteUri, 
but 
otherwise great find!

Original comment by mikej...@gmail.com on 14 Feb 2009 at 11:52

GoogleCodeExporter commented 8 years ago
Google either needs to update the documentation with a code sample showing how 
to 
properly encode the URL, or update the client library. The other samples just 
will 
not work. hey langsamu, thanks for posting that trick. I was just about ripping 
my 
hair out trying to figure out what to do, so it's a great relief to finally 
have a 
workaround for this!

Original comment by seo.loca...@gmail.com on 19 Jun 2009 at 12:17