Reputation: 15734
Suppose I have a REST endpoint like this :
http://server/users/query
And I have parameters in my query : age, city, country
I want to do a GET request with those parameters.
Should I better pass the parameters in the url
? Or put something like this in the payload of my GET request.
"query": {
"age": "something",
"city": "something",
"country": "something"
}
Upvotes: 0
Views: 3317
Reputation: 131037
On my understanding, you have a collection of users and you want to get a representation of it. You should consider query parameters to filter your collection, as following:
http://[host]/api/users?age=something&city=something&country=something
And avoid GET
requests with a payload. See the quote from the RFC 7231:
A payload within a
GET
request message has no defined semantics; sending a payload body on aGET
request might cause some existing implementations to reject the request.
Upvotes: 2