Postman Fundamentals
In this chapter, we'll explore how to effectively use GET, POST, PUT, and DELETE requests in POSTMAN to interact with APIs.
GET requests are used to retrieve data from a specified resource, similar to accessing a website in a browser.
GET requests can include query parameters for filtering data.
URL: https://jsonplaceholder.typicode.com/users?id=2
To pass query parameters, you can either append them directly to the URL or use the Params
tab in POSTMAN to enter key-value pairs. POSTMAN will automatically append these parameters to the URL when you send the request.
POST requests are used to send data to a server to create or update a resource/record.
To send a POST request:
Select the POST method and enter the URL that handles the POST request.
Under the Body
tab, choose Raw
and JSON
format to send data.
Body Type: Select Body
> Raw
> JSON
Example JSON Body:
{ "title": "Foo", "body": "Content", "userId": 1 }
This will create a new post in the backend.
PUT requests update existing resources on the server.
To send a PUT request:
Select the PUT method and specify the URL of the resource to update.
Use the Body
tab to send data in form-data
or JSON
format.
Body Type: Select Body
> Raw
> JSON
Example JSON Body:
{ "title": "Good to go" }
DELETE requests delete resources from the server.
To send a DELETE request:
Select the DELETE method and specify the URL of the resource to delete.
Optionally, include data in form-data
or JSON
format in the request body.