Skip to content

Commit

Permalink
fix: body encoding for rest transport (#768)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vam-google authored Feb 5, 2021
1 parent eaac3e6 commit cc55a18
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
)

Expand Down

0 comments on commit cc55a18

Please sign in to comment.