Posts

Sending POST Requests in Postman: A Step-by-Step Guide

This tutorial aims to create a POST request in Postman and demonstrate how to execute it.

Table of Contents

What is a POST Request?

A POST request is one of the HTTP methods used to send data to a server to create or update a resource. When you make a POST request, you're asking the server to accept and store the data enclosed in the body of the request. This is commonly used when submitting forms on websites, creating new records in a database, or sending data to an API.

Here are a few real-life examples:
  1. Submitting a Form: When you fill out a registration form on a website and click "Submit," the data you entered (such as your name, email, password, etc.) is sent to the server using a POST request. The server then processes this data, creates a new user account, and stores it in the database.
  2. Creating a New Post: In a blogging platform, when you write a new blog post and click "Publish," the content of the post (title, body, tags, etc.) is sent to the server via a POST request. The server then adds this new post to the database.
  3. Uploading a File: If you're uploading an image or a document to a file-sharing service like Dropbox or Google Drive, this is typically done using a POST request. The file data is included in the body of the request, and the server saves the file to the appropriate location.
  4. Making API Calls: Many web APIs require data to be sent to them for processing. For example, if you're building an e-commerce website and want to add a new product to your inventory, you would send a POST request to the API with the product details (name, price, description, etc.). The API then creates a new product entry in the database.
We will use the following URL for this Postman tutorial.
https://restful-booker.herokuapp.com/booking/
Sample Request Body
{
	"firstname": "Ebrahim",
	"lastname": "Hossain",
	"totalprice": 1020,
	"depositpaid": true,
	"bookingdates": {
    	"checkin": "2024-03-06",
    	"checkout": "2024-03-11"
	},
	"additionalneeds": "Breakfast"
}
    

Implementation Steps

Make a collection

Please follow this post to learn how to create a Collection in Postman

Make a request to the Collection

Step 1: To create a new request, click on the 3 dots and select “Add request”.

Step 2: Once you create a new request, then you will get the following window:
Uploading: 183425 of 183425 bytes uploaded.

Provide the requested information.

Step 1: Enter the “name” in the request. Here, the name is “Create New Booking”.

Step 2: Enter the “URL” in the address bar.
Step 3: Now, select the “POST” request from the list of request methods.
Step 4: Add a Request Body to the Post request
Steps:
  1. Click on the Body
  2. Check the raw option
  3. Select the JSON



This is done to ensure that we send the request in the correct format that the server expects. 
The request body example mentioned at the beginning of the tutorial should be copied and pasted into the Postman request body. 

Step 5:
 Press the “Send” button.

Ensure that the Response has been validated

Format Type

Each request has a defined response to it as defined by the Content-Type header. That response can be in any format. Such as in the above example, we have a JSON code file.

Below are the various format types present in Postman.

JSON


Congratulations on finishing this tutorial and I hope you found it helpful! Happy learning!

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.