</>

Technology

Postman

Difficulty

Beginner

Interview Question

How do you send a POST request with a JSON payload in Postman?

Answer

Sending a POST Request with JSON in Postman

Step-by-Step

  1. Select POST from the method dropdown
  2. Enter the URL: https://reqres.in/api/users
  3. Click the Body tab
  4. Select "raw" radio button
  5. Select "JSON" from the format dropdown (changes Content-Type to application/json automatically)
  6. Enter the JSON body:
    JSON
    {
        "name": "John Doe",
        "job": "QA Engineer"
    }
    
  7. Click Send

Expected Response: 201 Created

JSON
{
    "name": "John Doe",
    "job": "QA Engineer",
    "id": "123",
    "createdAt": "2026-06-20T10:00:00.000Z"
}

Add a Test Script (Tests Tab)

JavaScript
pm.test("Status code is 201", function () {
    pm.response.to.have.status(201);
});

pm.test("Response has id", function () {
    const jsonData = pm.response.json();
    pm.expect(jsonData.id).to.be.a('string');
});

pm.test("Name matches", function () {
    const jsonData = pm.response.json();
    pm.expect(jsonData.name).to.eql("John Doe");
});

Tips

  • Always set Content-Type: application/json header (Postman does this automatically when you select JSON in Body > raw)
  • Use environment variables for dynamic data: "name": "{{userName}}"
  • Use Pre-request Scripts to generate dynamic values before sending:
    JavaScript
    pm.environment.set("userName", "User_" + Date.now());
    

Follow AutomateQA

Related Topics