0
0
Postmantesting~20 mins

POST request in Postman - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
POST Request Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the response status code for this POST request?
Consider this Postman test script snippet that sends a POST request to create a new user. What will be the status code in the response if the user is created successfully?
Postman
pm.test('Status code is 201', function () {
    pm.response.to.have.status(201);
});
A200
B404
C400
D201
Attempts:
2 left
💡 Hint
201 means resource created successfully.
assertion
intermediate
2:00remaining
Which assertion correctly verifies the JSON response contains the new user's id?
You send a POST request to create a user. The response JSON contains an 'id' field. Which Postman test assertion correctly checks that the 'id' field exists and is not null?
Apm.expect(pm.response.json().id).to.exist;
Bpm.expect(pm.response.json().id).to.be.undefined;
Cpm.expect(pm.response.json().id).to.be.null;
Dpm.expect(pm.response.json().id).to.equal('');
Attempts:
2 left
💡 Hint
The id should exist and not be null or undefined.
🧠 Conceptual
advanced
2:00remaining
What is the main purpose of using POST requests in API testing?
In API testing, why do we use POST requests instead of GET requests?
ATo create new resources or submit data to the server
BTo update existing data partially on the server
CTo retrieve data from the server without changing it
DTo delete resources from the server
Attempts:
2 left
💡 Hint
POST is used to send data to the server to create something new.
🔧 Debug
advanced
2:00remaining
Why does this Postman test fail when checking the response body?
Given this test script after a POST request, why does it fail? pm.test('Response has name', function () { pm.expect(pm.response.text()).to.include('name'); });
AThe 'name' field is missing in the response JSON
Bpm.expect cannot be used with pm.response.text()
CThe response is JSON, so pm.response.text() returns a string, not parsed JSON
DThe test syntax is incorrect and missing a semicolon
Attempts:
2 left
💡 Hint
Check if the response is parsed JSON or plain text.
framework
expert
3:00remaining
Which Postman test script correctly validates a POST response with nested JSON and status 201?
You send a POST request that returns a JSON response with this structure: { "user": { "id": 123, "profile": { "email": "test@example.com" } } } Which test script correctly asserts the status is 201 and the email is 'test@example.com'?
A
pm.test('Status and email', () => {
  pm.response.to.have.status(200);
  pm.expect(pm.response.json().user.email).to.eql('test@example.com');
});
B
pm.test('Status and email', () => {
  pm.response.to.have.status(201);
  pm.expect(pm.response.json().user.profile.email).to.eql('test@example.com');
});
C
pm.test('Status and email', () => {
  pm.response.to.have.status(201);
  pm.expect(pm.response.json().profile.email).to.eql('test@example.com');
});
D
pm.test('Status and email', () => {
  pm.response.to.have.status(201);
  pm.expect(pm.response.json().user.profile.email).to.equal('wrong@example.com');
});
Attempts:
2 left
💡 Hint
Check the JSON path and status code carefully.