Some methods don't specify a schema for their response, which means that
they are returning non-JSON such as CSV, images, etc. In that case
we return the bytes on the wire instead of trying to parse the response
as JSON.
Reviewed in http://codereview.appspot.com/5448123/
diff --git a/apiclient/discovery.py b/apiclient/discovery.py
index a3d4beb..ca26025 100644
--- a/apiclient/discovery.py
+++ b/apiclient/discovery.py
@@ -52,6 +52,7 @@
from http import MediaUpload
from http import MediaFileUpload
from model import JsonModel
+from model import RawModel
URITEMPLATE = re.compile('{[^}]*}')
VARNAME = re.compile('[a-zA-Z0-9_-]+')
@@ -437,8 +438,13 @@
if self._developerKey:
actual_query_params['key'] = self._developerKey
+ model = self._model
+ # If there is no schema for the response then presume a binary blob.
+ if 'response' not in methodDesc:
+ model = RawModel()
+
headers = {}
- headers, params, query, body = self._model.request(headers,
+ headers, params, query, body = model.request(headers,
actual_path_params, actual_query_params, body_value)
expanded_url = uritemplate.expand(pathUrl, params)
@@ -541,7 +547,7 @@
logging.info('URL being requested: %s' % url)
return self._requestBuilder(self._http,
- self._model.response,
+ model.response,
url,
method=httpMethod,
body=body,