Heriotze
<Gold Donor>
- 1,048
- 1,449
They are query params and request body. Query params can be used by all service calls (GET, POST, PUT, DELETE & also PATCH I believe) or just by the frontend code. They are usually used for call types that do not allow request bodies and are used to pass data into those calls in addition to whatever data is already included in the url path. It is usually very basic information that they are used to pass through because urls have a max size limitation. Right now I'm working on an application where we are using query params to pass pagination information through for GET calls so ?pageNumber=0&sortDir=ASC type of thing. It's outside of the scope of your question but frontend can also use them when they are attached to route paths. Many sites use ?debug=true to display additional debugging data in a frontend element.I don't know enough to even know how to ask this question correctly, but here goes -
I use Postman to construct and test the query parameters in REST API post or get calls. Some of them just take a URL to the api, then a bunch of parameters. Others, I have to enter a bunch of non-readable shit into the "body".
What is the difference between these? Is there a name for the distinction, or a name for one vs the others? I'm trying to understand the differences and importance between the two, but don't even know what to search for.
(Please tag me if you reply....this thread isn't in my usual rotation)
Request body is a lot more robust and can handle much more information. POST and PUT ( and PATCH but it's a weird type and also DELETE but it has very edge case uses for a body) pass data through a request body which is your non-readable shit. They are usually used to create or edit data so it's expected that there could be quite a bit of actual data to be passed through in a request payload. You can use request body and query params for the same call but I'm not sure what the benefits of that are outside of separation of concerns and knowing that the request body is only made up of data that will be going into the database and query params are data used to identify where in the database that data will go.
- 2