Saturday, November 16, 2024
Google search engine
HomeGuest BlogsPostman – Working, HTTP Request & Responses

Postman – Working, HTTP Request & Responses

APIApplication Programming Interface… If you’re a developer then this word is nothing new for you…

Being a developer, you know the importance of API in any kind of application. In simple terms, API is a defined set of rules with some defined methods of communication. With the help of API, software components can interact with each other. You might have implemented some kind of APIs (such as payment gateway APIs) in your application. 

Postman-Working-HTTP-Request-Responses

Implementing a quality API is really important to ensure fast development without compromising on the code quality. The best and popular tool for API testing among developers is Postman

In API testing we test the collection of APIs, and we check that whether your application fulfills the expectations of functionality, reliability, performance, and security. Also, we check that whether it returns the correct response or not. 

In API testing we check that whether the output is well-structured and useful for some other application or not. Depending on the input parameter we check the response, and we determine the time API is taking to extract the data and authorize the data to it. 

How Postman Works?

Postman sends the request to the webserver and then the server sends the response back to it. A user has to set all the headers and cookies API expects to check the response.  

You can install the postman from the link Postman. This tool provides a collection of API calls, and you need to follow these API calls for testing APIs of the application. You will find a dropdown list with multiple methods. 

You can select one of the methods from the given dropdown list. You will also have to include more information depending on the API call. This information are set as Authorization, Header, or body information. You just need to select one of the methods and send the request and get the response back.

Postman Working

Environment Variables in Postman

Some requests in POSTMAN require some specific information. You can make changes to these variables all at once instead of changing the variables in the endpoint manually. 

In the top right corner, you will get the option to set the environment variable. You can follow the steps given below to set the environment variable. 

  1. In the top right corner click on Manage Environment from Settings.
  2. Click on ADD button.
  3. Mention the Name of the environment.
  4. Mention key and value. This will be used as a variable in the collection later.

Add Collection

Collections are a bundle of requests. To create a collection, you can add an API call in the collection. You can reuse it in your application. A lot of organizations offer collections. You can import this in your postman and test it. If you have created a collection, you can export it or if you want the collection of others, you can import it. 

Your API call mainly uses two things…

1. HTTP Request

You make HTTP calls sending the HTTP Request. In HTTP request method includes Request Method, Request URL, Request Headers, Request Body, Pre-request Script, and Tests.

Let’s talk about these Request methods one by one… 

Request Methods: You will find several types of Request methods in POSTMAN. Depending on your requirements or test you can choose one of them. Mainly you will be using four request methods in your application. These methods are given below…

  • GET Request: To retrieve or fetch data
  • POST Request: To create and update data
  • PUT Request; To update data
  • DELETE Request: For deleting data

Request URL: You will find a long-width bar in Postman where you will have to enter the URL to make the HTTP request. 

Request Headers: In the request header, you enter the key value of the application. The two main key values are given below.

  • Content-Type: The format of data is specified by Content-Type. Mainly developers use JSON format in the content type.
  • Authorization: This information is included to identify the requester.

Request Body: In Postman, you will get the tab of Body where you can mention some specific information that needs to be sent with the request. You will get the option to send the data either in raw, binary, or any other form. Most of the time you will select raw form. You will also get the option of Pre-request scripts. This gets executed before a request is sent. In Postman, you are also allowed to write and run the test for each request. You can use JavaScript language for this.

2. HTTP Response

Once you send the request to Postman, you get the response back from the API that contains Body, Cookies, Headers, Tests, Status Code, and API Response time. Body and Header get organized in different tabs. Status code gets displayed in another tab with the time taken to complete the API call. Some important status codes are given below to verify the response.

  • 200– For successful request.
  • 201– For successful request and data was created
  • 204– For Empty Response
  • 400– For Bad Request. 
  • 401– For Unauthorized access. Authentication failed or the user does not have permission for the requested operation. 
  • 403– For Forbidden, Access Denied
  • 404– For data not found.
  • 405– For method not allowed or requested method is not supported.
  • 500– Internal server error.
  • 503– For Service unavailable

From the above explanation, you might have understood many things about Postman. How it works, how it is used for testing, request, response, and all the status code as well. Postman is the most popular tool among developers for API testing. There are many other tools as well, you can check out them as well, but the most popular one is POSTMAN and the reason behind its popularity is a lot of features included in it. 

Last Updated :
02 Oct, 2022
Like Article
Save Article


Previous

<!–

8 Min Read | Java

–>


Next


<!–

8 Min Read | Java

–>

Share your thoughts in the comments

RELATED ARTICLES

Most Popular

Recent Comments