Skip to content

Make Selenium Easy

And Keep It That Way

  • Home
  • Share
  • Toggle search form

Postman Tutorial Part 5 – Sending POST Request in Postman

Posted on 02/19/2025 By admin

As a part of Postman Tutorial – End to End, in this post, we will learn “How to send POST request in the Postman tool.“

  1. You should have a preferably native Postman app installed on your system.
  1. Restful-booker API
  2. GoRest API

I will use below POST APIs for this post to show the demo:-

  1. Create Booking – Creates a new booking
  2. Create User – Create a new user

Let’s explore and understand our example APIs.

URI – https://restful-booker.herokuapp.com/booking

HTTP Method – POST

Headers – Content-Type: application/json

Authorization – Not required

Request Payload – Edit data as you wish but do not change key name or add/remove keys.

{
    "firstname" : "Jim",
    "lastname" : "Brown",
    "totalprice" : 111,
    "depositpaid" : true,
    "bookingdates" : {
        "checkin" : "2018-01-01",
        "checkout" : "2019-01-01"
    },
    "additionalneeds" : "Breakfast"
}

URI – https://gorest.co.in/public-api/users/

HTTP Method – POST

Headers – Content-Type: application/json

Authorization – Bearer – Access Token

To get an access token you need to login to GoRest. Once you login using GMail or Facebook, you can get your access token.

Request Payload –

{
  "name": "Tenali Ramakrishna",
  "gender": "Male",
  "email": "[email protected]",
  "status": "Active"
}

An HTTP POST method is used to create a new resource in the collection of resources with a request body passed as a JSON/XML or in a different format. If a resource is created successfully by the endpoint or server, it returns a status code 201( Created) (Not always) and returns the response body. It may return 200 (OK) and 204 (No Content) status code as well based on how API is developed.

POST is not a safe method as it is related to data creation. It is also not idempotent and invoking two identical POST requests may result in two different resources containing the same information with just different resource ids. An API may have a check on duplicate records as well like email id or mobile number is not unique. In that case, a POST request may behave as idempotent.

A request body contains data that is used to create a new resource. For example – You want to register a user on some portal and you need to pass your name, age, and address. Here name, age, and address are parameters/keys that hold a value in a request body.

  1. Launch the Postman tool app.
  2. Open “Create a new request” template.
  3. Select the “POST” in HTTP methods dropdown.
  4. Pass the request URI in the address bar of Postman.
  5. Pass request payload
  6. Add authorization if applicable.
  7. Add headers if applicable.
  8. Click on “Send” button.
  9. View the response body and other details.

I will demo Create Booking API followed by Create User API.

Launch the installed Postman tool. If you have not installed the Postman tool then you can install it from here. Please note here that I have created an account on Postman. If you have not created then you will be seeing some slightly different screen from below:-

There are many ways to open a request template in Postman. You can use any option shown below:-

A request template will be shown as below:-

Since a POST request is responsible to create a new resource, it requires data to work on. A POST API may ask for data in multiple ways. Our both example APIs take a JSON payload as a body.

To pass a JSON payload as body follow the below steps:-

  1. Click on “Body” tab.
  2. Select “raw” radio button.
  3. Select “JSON” from the last dropdown.
  4. Copy-paste JSON body in the body text area.

Create Booking API does not require any authentication. So I will skip this step. But for Create User API we require authentication which we will see after sometimes.

Headers represent the metadata of API requests and responses. A header is a key-value pair. Our example APIs accept a request payload as JSON which we need to let server know explicitly by adding a header named (key) “Content-Type” with value as “application/json”. All required header information will be provided in API doc by the developer. If it is not provided you need to ask them.

To add a header, follow the below steps:-

  1. Click on “Headers” tab.
  2. Enter header name as key in a row.
  3. Enter header value as value in corresponding row.

Postman will start giving suggestions while typing header names and values.

I have added only one header but it shows count as 10. Actually, Postman adds some default headers automatically which are hidden by default. You can see those by clicking on “9 hidden” which you can see in the above image.

Click on “Send” button and it will change to “Sending“. It means you need to wait until the response of API is received. Once request is processed you will get response below.

The Postman tool shows the response received in a Response section with status code, time taken to get a response, and size of the response.

For Create User API, follow the same steps as above. For “Authorization” step, we need to have an extra setup for this API as it requires authorization.

Details of the authentication mechanism of an API are provided in API doc. GoRest API’s authentication mechanism is provided on their website as below:-

There are three ways to pass authentication. We will Oauth2. Follow the steps as below:-

  1. Click on “Authorization” tab.
  2. Select “OAuth 2.0” in “Type” dropdown.
  3. Get the access token after creating an account on GoRest as shown above and paste in “Access Token” text box.

Note – I have just hide my access token by using stars(*).

Response is as below once you hit “Send” button.

You can subscribe to my YouTube channel RetargetCommon to learn from video tutorials.

If you have any doubt, feel free to comment below.If you like my posts, please like, comment, share and subscribe.#ThanksForReading

#HappyLearning

Uncategorized

Post navigation

Previous Post: TestNG Tutorials 21: Why Don’t We Require a Main Method In TestNG class For Execution Of Methods?
Next Post: TestNG Tutorials 15: Inheritance In TestNG Classes

Related Posts

September 7, 2019 – Make Selenium Easy Uncategorized
Advanced TestNG Tutorials 35: How To Pass Multiple Group Names to be Run at Runtime in TestNG XML Using Beanshell Uncategorized
DuplicateIn2DArray – Make Selenium Easy Uncategorized
Postman Tutorial Part 50 – How to Retrieve Request Body in Postman Uncategorized
September 17, 2018 – Make Selenium Easy Uncategorized
March 14, 2018 – Make Selenium Easy Uncategorized

Recent Posts

  • Getting Started with Selenium 4: What Is New and How to Upgrade from Selenium 3
  • Manual Testing
  • Baby Steps To Become Efficient Selenium-Java Automation Tester
  • Features of Selenium 4.0.0 Release – Java Binding
  • Part 1: Handling Drop-down Created Using SELECT Tag In Selenium

Recent Comments

No comments to show.

Archives

  • April 2026
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • April 2024
  • March 2024
  • February 2024
  • December 2023
  • October 2023
  • August 2023
  • November 2022
  • September 2022
  • August 2022
  • July 2022
  • May 2022
  • March 2022
  • October 2021
  • April 2021
  • March 2021
  • January 2021
  • December 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • May 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • January 2018

Categories

  • Getting Started
  • Uncategorized

Copyright © 2026 Make Selenium Easy.

Powered by PressBook Masonry Dark