WOE “GeoPlanet”: HTTP/1.1 406 Not Acceptable

November 19th, 2008

not simple polygons

Just putting a note here for the next time I’m working with the Yahoo! GeoPlanet APIs.

The conudrum: a HTTP GET on a given resource (http://where.yahooapis.com/v1/place/23511846?appid=$appid) works in the browser, and works with wget from the command line, but fails from within PHP with a 406 Not Acceptable.

The solution, append format=XML to the resource URL, because the service is blowing out its brains on a missing Accepts header.

And that folks is the magic of REST.

update 2008/12/04: quick scan of my referer logs suggests this is biting folks using lwp-simple and wget particularly hard.

2 responses to “WOE “GeoPlanet”: HTTP/1.1 406 Not Acceptable”

  1. Mike Malone says:

    To be fair, the documentation does say it defaults to whatever’s specified in the accept-header ;). It probably makes sense to have a default-default too though because, yaknow, why not? The bigger question is: why use xml when json fits the same amount of awesome in a smaller, quickly parsed, and more comprehensible package?

  2. Kellan says:

    Hey Mike,

    The documentation I read said this:

    “The API is accessed via HTTP GET.


    Find the WOEID of a significant landmark: http://where.yahooapis.com/v1/places.q('sydney%20opera%20house‘)?appid=[yourappidhere]” “

    I don’t think I should have to read any more then that to make a simple API call. Nowhere in there is there a mention of “this will break if you don’t use the full feature set of an HTTP 1.1 compliant HTTP client”. In fact the implication is quite the opposite.

    But yeah, mostly the lack of a default is just brain damage, RESTful brain damage :)