Closed mxmz closed 10 years ago
Hmm is there a more precise way to parse the errors? I just used success='0'
as a hack until I discovered the "real" way
Do we really need to parse error responses? Couldn't we just rely on status codes? Or do you have evidence of Google responding 200 even when some error occured? Or am I missing something?
Well you can have misformatted fields, missing fields, and few other cases. I would imagine that these would all come under 400, and it would be nice to provide these err
s to the user. I guess in the meantime, status code will do. The source is reasonably simple, PR :) ?
Actually, it turns out that this API does respond 200 with XML content under some error conditions, like ill-formed XML input or invalid values. Note that, if you add "alt=json", the Content-Type will be "application/json", but the body will still be XML (sic). When status code != 200, the Content-Type is text/html and body may or may not be a complete HTML document. Sometimes it's just a bare string.
Okay, so it seems like some time will need to be taken to ensure this is done right. Will flag this as awaiting a PR as I won't have much time in next few months
If response.statusCode != 200 and body doesn't include
"success='0'"
(which, for example, occurs if your token has expired), no error is reported.