Skip to content

Commit 52ae293

Browse files
committed
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.
1 parent eaac3e6 commit 52ae293

File tree

1 file changed

+1
-1
lines changed
  • gapic/templates/%namespace/%name_%version/%sub/services/%service/transports

1 file changed

+1
-1
lines changed

gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest.py.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class {{ service.name }}RestTransport({{ service.name }}Transport):
198198
{% if not method.void %}response = {% endif %}self._session.{{ method.http_opt['verb'] }}(
199199
url
200200
{%- if 'body' in method.http_opt %},
201-
json=body,
201+
data=body,
202202
{%- endif %}
203203
)
204204

0 commit comments

Comments
 (0)