Send Post Request from PostMan to SpringBoot

In this post, we are going to see Step By Step Tutorial for sending Post Request from PostMan to SpringBoot, for Beginners and Developers.

Step 1: Open PostMan

Step 2: Click on New

image

Step 3: Select HTTP in the popup.

image 1
Select HTTP

Step 4: Select POST before the URL

image 2

Step 5: Give the PostMapping URL (Enter the endpoint URL) from your Springboot Application: Eg. http://localhost:8080/api/products

Step 6: Set Request Body

  1. Go to the Body tab.
  2. Select raw.
  3. Choose JSON from the drop down.
image 4

Enter the JSON data like below. (based on your Entity class fields in SpringBoot)

{
  "name": "Product 1",
  "description": "This is a test product",
  "price": 10000,
  "rating": 4,
  "stock": 5,
  "img": "image-url"
}

Step 7: Set Headers

  1. Go to the Headers tab.
  2. Add the following header:
    • Key: Content-Type
    • Value: application/json
image 3

Step 8: Send Request

Click Send.

Step 9: You will get Status:200 OK, if the request is Successful.

image 5

Step 10: Verify in Database:

You can verify if the data is saved in the database using a SELECT query:

SELECT * FROM products;

Step 11: On the other side, you can verify through GET Request through PostMan.

image 6