This is a call to the GBIF API. There is an intential error in the call that gives an error message from the server
com.spatial4j.core.exception.InvalidShapeException: Invalid latitude: latitudes are range -90 to 90: provided lat: [-125.0]
In R with httr
:
library(httr)
call <- "http://api.gbif.org/v0.9/occurrence/search?geometry=POLYGON((38.4 -125, 40.9 -125, 40.9 -121.8, 38.4 -121.8, 38.4 -125))"
a <- GET(call)
None of the metadata from the call, as far as I know, gives the error message.
You can parse the message out
library(XML)
doc = htmlParse(content(a, as="text"))
xpathSApply(doc, "//h1", xmlValue)
[1] "HTTP Status 500 - com.spatial4j.core.exception.InvalidShapeException: Invalid latitude: latitudes are range -90 to 90: provided lat: [-125.0]"
But I wonder if there is a general solution available in httr
that works beyond just this example.
Perhaps the server error above should be in the header?
The "reason phrases" are suggestions: http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Status_codes so if the server wants to say something more explanatory it could!