From 52ae29376dccfe28a3709beabf0bea587acb9c02 Mon Sep 17 00:00:00 2001 From: vam-google Date: Thu, 4 Feb 2021 16:45:08 -0800 Subject: [PATCH 1/2] fix: body encoding for rest transport Basically just replace `json` argument with `data` Apparently, the `json` parameter in requests.Session.request() method does not expect JSON string, but expects python dictionary instead, which is not intuitive and does not even match the documentation of the method: https://github.com/psf/requests/blob/master/requests/sessions.py#L483. At the same time in the Quickstart, it is explicitly said that `json` parameter was added in version `2.4.2` and expects python `dict`, while `data` argument can process raw encoded json string. --- .../%name_%version/%sub/services/%service/transports/rest.py.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest.py.j2 b/gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest.py.j2 index 060e5d0744..1341571e48 100644 --- a/gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest.py.j2 +++ b/gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest.py.j2 @@ -198,7 +198,7 @@ class {{ service.name }}RestTransport({{ service.name }}Transport): {% if not method.void %}response = {% endif %}self._session.{{ method.http_opt['verb'] }}( url {%- if 'body' in method.http_opt %}, - json=body, + data=body, {%- endif %} ) From 0f3aeb99c6ffc3a98b9b30670885af72734e5c83 Mon Sep 17 00:00:00 2001 From: vam-google Date: Thu, 4 Feb 2021 17:07:32 -0800 Subject: [PATCH 2/2] Trigger CI