grpc-gateway
grpc-gateway copied to clipboard
allow request body in GET
adding request body in GET RPC getting the below error Failure: plugin openapiv2: must not set request body when http method is GET: GetDiagnosis
I am aware of setting allow_delete_body=true in opt, which allows a request body for DELETE , is same can be done with GET?
Though it is not a good practice to send body in GET ,but I have a situation as such.
There's no support for setting request bodies in GET requests, my understanding is that the HTTP spec allows them but also that servers should ignore them, so I don't think we're going to allow it. Do you have information you aren't able to pass as path or query parameters?
If you use the fetch API in JS, this will not work and trigger the following error.
Uncaught (in promise) TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body.
Even if XHR allows that, the RFC says following:
There are proxies that will definitely break your request in various ways if you include a body on GET. Avoid troubles and don't do it.