Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit cc55a18

Browse files
authored
fix: body encoding for rest transport (#768)
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 cc55a18

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • gapic/templates/%namespace/%name_%version/%sub/services/%service/transports

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)