Now using the dataWrapper features flag to control serialization of JSON requests.
diff --git a/apiclient/discovery.py b/apiclient/discovery.py
index b7bc823..7ae6a8a 100644
--- a/apiclient/discovery.py
+++ b/apiclient/discovery.py
@@ -68,7 +68,7 @@
http=None,
discoveryServiceUrl=DISCOVERY_URI,
developerKey=None,
- model=JsonModel(),
+ model=None,
requestBuilder=HttpRequest):
"""Construct a Resource for interacting with an API.
@@ -125,7 +125,7 @@
future=None,
http=None,
developerKey=None,
- model=JsonModel(),
+ model=None,
requestBuilder=HttpRequest):
"""Create a Resource for interacting with an API.
@@ -160,6 +160,8 @@
future = {}
auth_discovery = {}
+ if model is None:
+ model = JsonModel('dataWrapper' in service.get('features', []))
resource = createResource(http, base, model, requestBuilder, developerKey,
service, future)
diff --git a/apiclient/http.py b/apiclient/http.py
index f713ec8..094271f 100644
--- a/apiclient/http.py
+++ b/apiclient/http.py
@@ -150,7 +150,7 @@
resp, content = self.responses[methodId]
return HttpRequestMock(resp, content, postproc)
else:
- model = JsonModel()
+ model = JsonModel(False)
return HttpRequestMock(None, '{}', model.response)
diff --git a/apiclient/model.py b/apiclient/model.py
index 58cd624..55bcc94 100644
--- a/apiclient/model.py
+++ b/apiclient/model.py
@@ -73,6 +73,14 @@
object representation of HTTP request and response bodies.
"""
+ def __init__(self, data_wrapper):
+ """Construct a JsonModel
+
+ Args:
+ data_wrapper: boolean, wrap requests and responses in a data wrapper
+ """
+ self._data_wrapper = data_wrapper
+
def request(self, headers, path_params, query_params, body_value):
"""Updates outgoing requests with JSON bodies.
@@ -97,6 +105,10 @@
else:
headers['user-agent'] = ''
headers['user-agent'] += 'google-api-python-client/1.0'
+
+ if (isinstance(body_value, dict) and 'data' not in body_value and
+ self._data_wrapper):
+ body_value = {'data': body_value}
if body_value is None:
return (headers, path_params, query, None)
else: