Hi. Why I can’t request GET request with body?
# ktor
r
Hi. Why I can’t request GET request with body?
b
You can via generic http request builder, but this is going against REST conventions.
All the input for get requests should be passed in via path or query params, so it's gettable from the browser
🙏 1
c
its not only against rest conventions, its against the http standard
r
But other libs works with get request body
b
Ktor can do it too. It just doesn't expose dsl for it as it's an antipattern
c
some http clients dont support it like okhttp or the javascript fetch api
“So, yes, you can send a body with GET, and no, it is never useful to do so.” https://stackoverflow.com/questions/978061/http-get-with-request-body
i know some rest apis that define get requests with bodies, but it has always worked for me to send the fields as query parameters instead
j
If there is too much data to be send out, it should be a POST
Too much data-> If it doesn't fit in the URL anymore 🙂
c
if it changes state it should be a post or put.
b
Don't forget that url queries support lists too. I find that to be the main blocker for ppl not knowing it.