A POST request is used to send data to a server to create or update a resource. It usually includes data in the request body.
Click to reveal answer
beginner
In Postman, where do you add the data for a POST request?
You add the data in the 'Body' tab of the Postman interface, usually in formats like JSON, form-data, or x-www-form-urlencoded.
Click to reveal answer
beginner
Why do we use POST requests instead of GET for sending data?
POST requests send data in the request body, which is more secure and can handle larger amounts of data. GET requests send data in the URL, which is limited and less secure.
Click to reveal answer
intermediate
What HTTP status code usually indicates a successful POST request?
The status code 201 means 'Created', indicating the POST request successfully created a resource. Sometimes 200 (OK) is also used.
Click to reveal answer
intermediate
How can you validate the response of a POST request in Postman?
You can write tests in the 'Tests' tab using JavaScript to check status codes, response body content, headers, and more.
Click to reveal answer
What is the main purpose of a POST request?
ATo retrieve data from the server
BTo send data to the server to create or update a resource
CTo delete a resource on the server
DTo update data using URL parameters
✗ Incorrect
POST requests send data in the request body to create or update resources on the server.
Where do you add the data payload in Postman for a POST request?
AIn the Body tab
BIn the Headers tab
CIn the Params tab
DIn the Authorization tab
✗ Incorrect
The Body tab is where you add the data to send with a POST request.
Which HTTP status code indicates a resource was successfully created by a POST request?
A500
B404
C201
D301
✗ Incorrect
201 means 'Created', showing the POST request succeeded in creating a resource.
Why is POST preferred over GET for sending sensitive data?
APOST sends data in the request body, which is not visible in the URL
BPOST sends data in the URL
CGET encrypts data automatically
DGET can send larger data than POST
✗ Incorrect
POST sends data in the body, keeping it hidden from the URL and browser history.
How can you check the response status code in Postman tests?
Apm.test.status(200);
Bpm.request.to.have.status(201);
Cpm.response.statusCode(404);
Dpm.response.to.have.status(201);
✗ Incorrect
The correct syntax to check status code 201 in Postman tests is pm.response.to.have.status(201);
Explain how to create and test a POST request in Postman.
Think about the steps from setting up the request to validating the response.
You got /6 concepts.
Describe the difference between POST and GET requests in simple terms.
Focus on where data is sent and the purpose of each request.
You got /5 concepts.
Practice
(1/5)
1. What is the main purpose of a POST request in API testing?
easy
A. To send data to the server to create or update a resource
B. To retrieve data from the server without changing it
C. To delete a resource from the server
D. To check the server status without sending data
Solution
Step 1: Understand HTTP methods
HTTP methods define actions: GET retrieves data, POST sends data to create or update resources.
Step 2: Identify POST request purpose
POST requests include a body with data to be processed by the server, usually creating or updating resources.
Final Answer:
To send data to the server to create or update a resource -> Option A
Quick Check:
POST = send data to create/update [OK]
Hint: POST sends data to server to create or update [OK]
Common Mistakes:
Confusing POST with GET which only retrieves data
Thinking POST deletes data instead of creating/updating
Assuming POST does not send a request body
2. Which of the following is the correct way to set the body of a POST request in Postman using JSON?
easy
A. Select 'Headers' tab and add JSON data as header values
B. Select 'Params' tab and enter JSON data as key-value pairs
C. Select 'Authorization' tab and paste JSON data
D. Select 'Body' tab, choose 'raw', then select 'JSON' from dropdown and enter JSON data
Solution
Step 1: Locate body settings in Postman
In Postman, the 'Body' tab is used to send data with POST requests.
Step 2: Choose raw and JSON format
Within 'Body', selecting 'raw' and then 'JSON' allows entering JSON formatted data correctly.
Final Answer:
Select 'Body' tab, choose 'raw', then select 'JSON' from dropdown and enter JSON data -> Option D
Quick Check:
Body tab + raw + JSON = correct POST body setup [OK]
Hint: Use Body > raw > JSON to send JSON data [OK]
Common Mistakes:
Entering JSON in Params tab which is for URL parameters
Putting JSON data in Headers which is for metadata
Confusing Authorization tab with body data input
3. Given this Postman test script for a POST request response:
But the test always fails with error TypeError: Cannot read property 'message' of undefined. What is the most likely cause?
medium
A. The server returned status 404
B. The test syntax is incorrect
C. Response body is empty or not valid JSON
D. The Postman app is outdated
Solution
Step 1: Understand the error message
The error means pm.response.json() returned undefined, so accessing .message fails.
Step 2: Identify cause of undefined JSON
This usually happens if response body is empty or not valid JSON, so parsing fails.
Final Answer:
Response body is empty or not valid JSON -> Option C
Quick Check:
Empty or invalid JSON causes undefined error [OK]
Hint: Check if response body is valid JSON before accessing properties [OK]
Common Mistakes:
Blaming test syntax instead of response content
Ignoring server status codes affecting response body
Assuming Postman app version causes this error
5. You want to test a POST request that creates a new user with fields name and email. Which Postman test script correctly verifies the server response includes the same email you sent and a status code 201?
hard
A. pm.test('Status 201 and email match', () => {
pm.response.to.have.status(201);
const res = pm.response.json();
pm.expect(res.email).to.eql(pm.request.body.raw.email);
});
B. pm.test('Status 201 and email match', () => {
pm.response.to.have.status(201);
const res = pm.response.json();
const req = JSON.parse(pm.request.body.raw);
pm.expect(res.email).to.eql(req.email);
});
C. pm.test('Status 201 and email match', () => {
pm.response.to.have.status(200);
const res = pm.response.json();
pm.expect(res.email).to.eql('test@example.com');
});
D. pm.test('Status 201 and email match', () => {
pm.response.to.have.status(201);
pm.expect(pm.response.json().email).to.exist;
});
Solution
Step 1: Check status code assertion
The test must check for status 201, which indicates resource creation.
Step 2: Compare response email with request email
Since request body is raw JSON string, parse it with JSON.parse(pm.request.body.raw) to access email for comparison.
Step 3: Validate correct assertion
pm.test('Status 201 and email match', () => {
pm.response.to.have.status(201);
const res = pm.response.json();
const req = JSON.parse(pm.request.body.raw);
pm.expect(res.email).to.eql(req.email);
}); correctly parses request body and compares res.email with req.email, ensuring they match.
Final Answer:
pm.test('Status 201 and email match', () => {
pm.response.to.have.status(201);
const res = pm.response.json();
const req = JSON.parse(pm.request.body.raw);
pm.expect(res.email).to.eql(req.email);
}); -> Option B
Quick Check:
Parse request body JSON before comparing fields [OK]
Hint: Parse request body JSON to compare fields in tests [OK]
Common Mistakes:
Trying to access pm.request.body.raw.email directly without parsing
Checking wrong status code like 200 instead of 201
Only checking email exists without matching request value
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.