I encountered problems with Google Sheet API these few days, all response message I can get from Requests (by way of requests_oauthlib extension) is the headers & 400 Bad Request. Requests version is 2.19.1. This happened with several endpoints (v4), like spreadsheets.values.append, spreadsheets.values.batchUpdate, spreadsheets.values.update, etc.
I've wasted hours making sure I have formed the correct data structure to no avail, and only then I realized I didn't get the whole response message from the API server.
It seems since requests.Response object that gets returned from r = request.Request('https://httpbin.org') is from a requests.HTTPAdapter object, which in turn is sort of a wrapper for urllib3.response.HTTPResponse. So I tried to use r.reason, r.raw._original_response, r.raw._body, r.raw.msg which didn't give me anything but object reference & None (or just empty string).
Long story short, I gave up for a while & when got back to it I realized I should've tried using Google's API explorer that i've been ignoring, and it turned out there is an error message in the response, and the 400 error wasn't due to any bad payload/data structure form.
{ "error": {
"code": 400,
"message": "Invalid data[0]: Requested writing within range [mysheet!A3:AH3], but tried writing to row [4]",
"status": "INVALID_ARGUMENT" }
}
My question is:
Was I wrong in how I debug connection response from requests & actually there's a method to get the full raw message from the server in requests like a full debug mode in curl? Or is this message is actually only sent if the API request comes from Google API explorer?