I am trying to send a get request to my API to get a list of users. But I need there is an exclude list that the response must exclude. How can I send this exclude list in my GET request?
CodePudding user response:
You cannot send a request body when making a GET request. However, you can add it as a query parameter. Alternatively, you can make a POST request.
CodePudding user response:
You can send a body with the request. Query parameters is probably the best way to do it though. The folks at Elastic.co say:
The truth is that RFC 7231—the RFC that deals with HTTP semantics and content—does not define what should happen to a GET request with a body! As a result, some HTTP servers allow it, and some—especially caching proxies—don’t.
The authors of Elasticsearch prefer using GET for a search request because they feel that it describes the action—retrieving information—better than the POST verb. However, because GET with a request body is not universally supported, the search API also accepts POST requests: