What is the limit exceeded error code or ErrorMessage retrieved as a JSONObject in yahoo api?

StackOverflow https://stackoverflow.com/questions/22369961

  •  13-06-2023
  •  | 
  •  

Question

I found this error message for yahoo api when the limit is exceeded can anyone tell me what it would return as a Json object and not in xml format?

Was it helpful?

Solution

From the geocoder gem

##
# Yahoo returns errors as XML even when JSON format is specified.
# Handle that here, without parsing the XML
# (which would add unnecessary complexity).
# Yahoo auth errors can also be cryptic, so add raw error desc
# to warning message.
#
def parse_raw_data(raw_data)
  if raw_data.match(/^<\?xml/)
    if raw_data.include?("Rate Limit Exceeded")
      raise_error(Geocoder::OverQueryLimitError) || warn("Over API query limit.")
    elsif raw_data =~ /<yahoo:description>(Please provide valid credentials.*)<\/yahoo:description>/i
      raise_error(Geocoder::InvalidApiKey) || warn("Invalid API key. Error response: #{$1}")
    end
  else
    super(raw_data)
  end
end

So it seems that you question cannot be answered because it will not return a jSON response from Yahoo API. It will always return XML format

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top