This article will give you insights on the Postman tool and how to perform GET, POST, PUT and DELETE operations.
What is Postman?
It is a tool which comes handy while testing the API functionalities. We can test an API by proving the rest mapping path and get a response.
Lets look at the points one by one.
1: Method Requests.
This specifies how the API is mapped. i.e Is it GET mapping or Post mapping or Put Mapping or Delete.There are multiple Method requests as shown in the image but 4 of them are most commonly used i.e
From here we can call our API. We need to give the mapping here.
eg: in the above case the url is:
postman/getuser : Request mapping
3. Variable mappers
i) Params : This is used when we need to give the parameters to the API, eg: key- value.
ii) Authorization: used for proper authentication to access API.
iii) Headers : used to set headers passed to the API.
iv) Body : used while passing the request body to the API. There are multiple formats in which we can send the request body, eg: raw, binary etc.
v) Pre-request Script: Script that needs to be executed before the request is made
vi) Tests: Tests scripts executed while the request is made.
4. Request Space:
We can pass the request body or headers in this area.
5. Response status received after the request is made.
6. Response area.
To Understand the working of each request, i recommend to go through the source code.
Get mapping is done when we want to get the data from the API by passing the url and headers if required.
Eg: The following request will get me all the users and their related information.Screenshot from 2021–03–23 20–19–49
Post Mapping is done when we want to insert an object. In this case I am passing the object values in the form of json.
This is basically used when we need to update an object. We can pass parameters such as user id.
It is basically used when we want to delete a particular user.