fix: 458 handle error format (#459)
diff --git a/googleapiclient/http.py b/googleapiclient/http.py
index 7992ea3..eb46449 100644
--- a/googleapiclient/http.py
+++ b/googleapiclient/http.py
@@ -89,7 +89,7 @@
Args:
resp_status: The response status received.
- content: The response content body.
+ content: The response content body.
Returns:
True if the response should be retried, otherwise False.
@@ -112,7 +112,10 @@
# Content is in JSON format.
try:
data = json.loads(content.decode('utf-8'))
- reason = data['error']['errors'][0]['reason']
+ if isinstance(data, dict):
+ reason = data['error']['errors'][0]['reason']
+ else:
+ reason = data[0]['error']['errors']['reason']
except (UnicodeDecodeError, ValueError, KeyError):
LOGGER.warning('Invalid JSON content from response: %s', content)
return False
@@ -510,7 +513,6 @@
Construct a MediaFileUpload and pass as the media_body parameter of the
method. For example, if we had a service that allowed uploading images:
-
media = MediaFileUpload('cow.png', mimetype='image/png',
chunksize=1024*1024, resumable=True)
farm.animals().insert(