Query Parameter vs Request Body
A query parameter goes in the address, after the question mark. Anyone can see it there. A request body goes inside the request, after the headers. Short filters go in the address; passwords, forms and files go in the body.
Query Parameter
A name and value added after a ? in a web address, like ?page=2.
A query parameter is a name and a value added to the end of a web address. It comes after a question mark. In /search?q=shoes&page=2, q and page are query parameters. Each pair is joined with an equals sign, and pairs are split by an ampersand. They are used to search, filter, sort and pick a page. Anyone can see them, so they must never hold secrets.
Request Body
The data sent inside a web request, after the headers. POST and PUT use one.
The request body is the data sent after the headers in a web request. It carries what you are sending, like a new user, a form or a file. POST, PUT and PATCH requests usually have one; GET and DELETE usually do not. A header called Content-Type says what format the body is in, such as JSON. A blank line separates the headers from the body.
In one line
- Query Parameter
- A name and value added after a ? in a web address, like ?page=2.
- Request Body
- The data sent inside a web request, after the headers. POST and PUT use one.