GET method doesn't support body payload #2277
-
|
It would be nice to be able to send a body with a GET request. I understand that this may not be considered a good practice, but this is necessary for the API that I have to work with. RFC 2616, section 4.3 clearly states:
However, in the entirety of section 9.3, the section defining the GET verb, nothing prevents a GET request from having a body. But before you draw any conclusions - the functionality defined for the GET verb also does not include any logic involving the message body. In other words, if we are to follow the specification:
Essentially, there is no point, per standard, to send a body with a GET request, even though it is not explicitly disallowed. Roy T. Fielding backs this interpretation up:
More about this: swagger-api/swagger-ui#2136 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
I know there is a way around this using |
Beta Was this translation helpful? Give feedback.
-
|
HTTPX does not disallow sending bodies on any method. We don’t allow it in the shortcut methods, but it is fully allowed with the usage you mentioned, which is not a workaround but the documented and supported way to do so, as per the Requests compatibility guide: https://www.python-httpx.org/compatibility/#request-body-on-http-methods
There has been extensive thinking behind this design decision and various discussions already. Please feel free to search through the issue tracker. I’ll move this to a discussion. Thanks! |
Beta Was this translation helpful? Give feedback.
Hi @ZhymabekRoman
HTTPX does not disallow sending bodies on any method. We don’t allow it in the shortcut methods, but it is fully allowed with the usage you mentioned, which is not a workaround but the documented and supported way to do so, as per the Requests compatibility guide:
https://www.python-httpx.org/compatibility/#request-body-on-http-methods
There has been extensive thinking behind this design decision and various discussions already. Pl…