You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add ability to send custom PUT and PATCH requests with JSON body #577
Bug description
We have a REST endpoint to update a datastructure that requires the use of the HTTP PUT method.
We're using request from the Context class to send a request to that endpoint.
On binding.py#L876, the _encode method is called, whose result is used to overwrite the original body parameter of the method. This causes the request-body to be url-encoded and url-formatted.
Steps to reproduce the behavior:
Send a HTTP PUT request with a JSON body to an endpoint, using the request method of the Context class.
Expected behavior
The request method correctly escapes a JSON body, or provides instructions on how to call it to prevent the URL-encoding.
Logs or Screenshots
Currently, our REST endpoint receives a payload similar to this:
The original issue description is a bit imprecise.
The post method of the service allows sdk users to pass the body param as a string - this leads to the service class skipping the encoding, as opposed to automatic encoding if a dict is passed. However, the request method (as a stand-in for the missing put and patch method) does not behave the same way. It would force us to check if we're working with form-data or with stringified JSON in our script endpoints.
Our desire is for the sdk API to be persistent so that we can use put and patch the same way we can use post - with stringified JSON, which we escape ourselves.
You can find an implementation for put and patch here: #586
If adding put and patch to the sdk is not an option, a check similar to the one in post before encoding the body in the generic request method would be feasible as well.
changed the title [-]binding.py // Context.request URL-encodes request body[/-][+]Add ability to send custom `PUT` and `PATCH` requests with JSON body[/+]on Sep 15, 2025
Activity
seiimonn commentedon Aug 19, 2024
Hi team!
Could we please get a response on this?
It seems to be a minor fix!
Thank you!
Ickerday commentedon Sep 8, 2025
Dismissed as stale. Please tell us if the issue persists!
seiimonn commentedon Sep 9, 2025
@Ickerday, this is not stale and still makes using the SDK infeasible.
Ickerday commentedon Sep 9, 2025
Thanks @seiimonn, we're taking a look!
mateusz834 commentedon Sep 9, 2025
Could you provide us with a complete reproducer?
From the description i assume you are doing something like:
I observe that in such case we are sending following HTTP body:
Which decodes successfully:
moschi commentedon Sep 9, 2025
The original issue description is a bit imprecise.
The
postmethod of the service allows sdk users to pass thebodyparam as a string - this leads to the service class skipping the encoding, as opposed to automatic encoding if a dict is passed. However, therequestmethod (as a stand-in for the missingputandpatchmethod) does not behave the same way. It would force us to check if we're working with form-data or with stringified JSON in our script endpoints.Our desire is for the sdk API to be persistent so that we can use
putandpatchthe same way we can usepost- with stringified JSON, which we escape ourselves.You can find an implementation for
putandpatchhere: #586If adding
putandpatchto the sdk is not an option, a check similar to the one inpostbefore encoding the body in the genericrequestmethod would be feasible as well.[-]binding.py // Context.request URL-encodes request body[/-][+]Add ability to send custom `PUT` and `PATCH` requests with JSON body[/+]Support string body in the generic request method
mateusz834 commentedon Nov 5, 2025
So we plan to support both ways to make it consistent:
I sent: #683 (which add more tests and implements the logic in the request method).
We also plan to go with #586, so that we are consistent. We are waiting for @seiimonn to get that change rebased on top of the develop branch.
Support string body in the generic request method
Support string body in the generic request method
seiimonn commentedon Nov 6, 2025
Hi @mateusz834 - did the rebase!
Support string body in the generic request method
Support string body in the generic request method
Support setting string body in the generic `request` method (#683)