REST GET with body/payload #44616
-
Am i doing something wrong with my test application? The second endpoint under curl -X 'GET' \
'http://localhost:8080/hello/String' \
-H 'accept: text/plain' \
-H 'Content-Type: application/json' \
-d '{
"majs": "string",
"mango": "string",
"kalle": true,
"räknare": 0
}' Should it be this way? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Why exactly are you trying to post a payload with GET? Because it's not really what you should do. You can pass parameters in the URI but if you want to post an actual payload, you should use POST or PUT. |
Beta Was this translation helpful? Give feedback.
-
Mostly because of an internal discussion regarding allowing use of post methods to get data and including concerns regarding maximum length of query parameters when used from a browser, curl, axios or JavaScript fetch.
|
Beta Was this translation helpful? Give feedback.
-
Also since the RFC 9110 states this
A client SHOULD NOT generate content in a GET request unless it is made directly to an origin server that has previously indicated, in or out of band, that such a request has a purpose and will be adequately supported. An origin server SHOULD NOT rely on private agreements to receive content, since participants in HTTP communication are often unaware of intermediaries along the request chain.
https://www.rfc-editor.org/rfc/rfc9110#section-9.3.1-6
|
Beta Was this translation helpful? Give feedback.
Well, GET methods are definitely not designed to post a body. I dunno if we support it with Quarkus - it might work - but as you have experienced, a lot of tooling will fail.
I would recommend that you avoid that altogether.