Bird
Raised Fist0
Postmantesting~20 mins

Send request block in Postman - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Postman Request Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
What is the result of this Postman test script?

Given this Postman test script inside the Tests tab, what will be the test result after sending the request?

Postman
pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});
pm.test("Response has userId", function () {
    const jsonData = pm.response.json();
    pm.expect(jsonData).to.have.property('userId');
});
ABoth tests pass if the response status is 200 and JSON contains 'userId' property.
BThe tests pass regardless of response content or status.
CBoth tests fail if the response is not JSON format.
DThe first test fails if status is 200; the second test always passes.
Attempts:
2 left
💡 Hint

Check the response status and JSON structure before running tests.

❓ assertion
intermediate
1:30remaining
Which assertion correctly checks that response time is less than 500ms?

Choose the Postman test assertion that will pass only if the response time is under 500 milliseconds.

Apm.test('Response time is less than 500ms', () => { pm.expect(pm.response.time).to.be.below(500); });
Bpm.test('Response time is less than 500ms', () => { pm.expect(pm.response.responseTime).to.be.above(500); });
Cpm.test('Response time is less than 500ms', () => { pm.expect(pm.response.responseTime).to.be.below(500); });
Dpm.test('Response time is less than 500ms', () => { pm.expect(pm.response.responseTime).to.equal(500); });
Attempts:
2 left
💡 Hint

Look for the property that holds response time in milliseconds and the correct comparison.

❓ locator
advanced
2:00remaining
Which Postman test code correctly extracts the 'token' from a nested JSON response?

Given this JSON response:

{
  "data": {
    "auth": {
      "token": "abc123xyz"
    }
  }
}

Which code snippet correctly saves the token value into a variable?

Aconst token = pm.response.json().auth.token;
Bconst token = pm.response.json().data.auth.token;
Cconst token = pm.response.json().data.token;
Dconst token = pm.response.json().token;
Attempts:
2 left
💡 Hint

Follow the JSON structure step-by-step to reach the token.

🔧 Debug
advanced
2:00remaining
Why does this Postman test script throw an error?

Consider this test script:

pm.test('Check user name', () => {
  const jsonData = pm.response.json;
  pm.expect(jsonData.name).to.eql('Alice');
});

What causes the error during execution?

Apm.response.json is a function and must be called with parentheses.
Bpm.expect cannot compare strings with to.eql.
CThe property 'name' does not exist in the response.
Dpm.test requires a callback with no parameters.
Attempts:
2 left
💡 Hint

Check how to properly parse JSON response in Postman scripts.

❓ framework
expert
3:00remaining
Which Postman test script block correctly runs multiple tests and reports all failures?

You want to run these tests in Postman and see all failures reported, not just stop at the first failure:

  • Status code is 200
  • Response time is less than 300ms
  • Response body contains 'success'

Which code block achieves this?

A
pm.test('Status code is 200', () => { pm.response.to.have.status(200); });
pm.test('Response time < 300ms', () => { pm.expect(pm.response.responseTime).to.be.above(300); });
pm.test('Body contains success', () => { pm.expect(pm.response.text()).to.include('success'); });
B
pm.test('All checks', () => {
  pm.response.to.have.status(200);
  pm.expect(pm.response.responseTime).to.be.below(300);
  pm.expect(pm.response.text()).to.include('success');
});
C
pm.test('All checks', () => {
  if(pm.response.code !== 200) throw new Error('Status code not 200');
  if(pm.response.responseTime >= 300) throw new Error('Response time too high');
  if(!pm.response.text().includes('success')) throw new Error('Missing success in body');
});
D
pm.test('Status code is 200', () => { pm.response.to.have.status(200); });
pm.test('Response time < 300ms', () => { pm.expect(pm.response.responseTime).to.be.below(300); });
pm.test('Body contains success', () => { pm.expect(pm.response.text()).to.include('success'); });
Attempts:
2 left
💡 Hint

Separate tests allow reporting all failures individually.

Practice

(1/5)
1. What is the main purpose of the Send request block in Postman?
easy
A. To call APIs and test their responses automatically
B. To design the user interface of an application
C. To write database queries
D. To create user accounts in Postman

Solution

  1. Step 1: Understand the role of Send request block

    The Send request block is used to make API calls and check how the API behaves.
  2. Step 2: Compare options with the purpose

    Only To call APIs and test their responses automatically correctly describes calling APIs and testing responses automatically.
  3. Final Answer:

    To call APIs and test their responses automatically -> Option A
  4. Quick Check:

    Send request block = call and test APIs [OK]
Hint: Send request block is for API calls and testing [OK]
Common Mistakes:
  • Confusing Send request with UI design
  • Thinking it writes database queries
  • Assuming it manages user accounts
2. Which of the following is the correct way to send a GET request using the Send request block in Postman scripts?
easy
A. pm.sendRequest({url: 'https://api.example.com', method: 'GET'}, callback);
B. pm.sendRequest('https://api.example.com', 'GET', callback);
C. sendRequest({url: 'https://api.example.com', method: 'GET'});
D. pm.requestSend({url: 'https://api.example.com', method: 'GET'}, callback);

Solution

  1. Step 1: Recall correct syntax for pm.sendRequest

    The correct syntax uses an object with url and method, plus a callback function.
  2. Step 2: Check each option's syntax

    pm.sendRequest({url: 'https://api.example.com', method: 'GET'}, callback); matches the correct syntax: pm.sendRequest({url: ..., method: ...}, callback); others have wrong function names or argument formats.
  3. Final Answer:

    pm.sendRequest({url: 'https://api.example.com', method: 'GET'}, callback); -> Option A
  4. Quick Check:

    pm.sendRequest uses object + callback [OK]
Hint: Use object with url and method in pm.sendRequest [OK]
Common Mistakes:
  • Passing URL and method as separate arguments
  • Using wrong function names like sendRequest or pm.requestSend
  • Omitting the callback function
3. Consider this Postman test script snippet:
pm.sendRequest({
  url: 'https://api.example.com/data',
  method: 'GET'
}, function (err, res) {
  pm.test('Status code is 200', function () {
    pm.expect(res.code).to.eql(200);
  });
});
What will happen when this script runs?
medium
A. The script will throw a syntax error
B. The test will fail because the callback is missing
C. The test will always pass regardless of status code
D. The test will pass if the API returns status 200

Solution

  1. Step 1: Analyze the sendRequest call and callback

    The script sends a GET request and uses a callback to check the response status code.
  2. Step 2: Understand the test assertion

    The test asserts that the response code equals 200, so it passes only if the API returns 200.
  3. Final Answer:

    The test will pass if the API returns status 200 -> Option D
  4. Quick Check:

    Test passes if res.code == 200 [OK]
Hint: Test passes only if response code matches 200 [OK]
Common Mistakes:
  • Thinking callback is missing
  • Assuming syntax error without checking code
  • Believing test passes regardless of response
4. You wrote this Postman script to send a request:
pm.sendRequest({
  url: 'https://api.example.com/users',
  method: 'POST',
  body: {
    mode: 'raw',
    raw: JSON.stringify({name: 'John'})
  }
}, function (err, res) {
  // callback function
});
But the request is not sent. What is the likely problem?
medium
A. Incorrect HTTP method; POST is not allowed
B. Missing callback function to handle the response
C. Body should be sent as form-data, not raw JSON
D. URL is invalid and causes failure

Solution

  1. Step 1: Check the sendRequest syntax

    pm.sendRequest requires a callback function as the second argument to execute the request properly.
  2. Step 2: Identify missing callback

    The script lacks the callback function, so the request is not sent or handled.
  3. Final Answer:

    Missing callback function to handle the response -> Option B
  4. Quick Check:

    sendRequest needs callback to send request [OK]
Hint: Always include callback function in pm.sendRequest [OK]
Common Mistakes:
  • Ignoring the need for callback function
  • Assuming HTTP method is wrong without checking API docs
  • Thinking body format is always wrong
  • Blaming URL without testing it
5. You want to send a POST request with JSON data and verify the response contains a field success set to true. Which Postman script correctly sends the request and tests the response?
hard
A. pm.sendRequest({url: 'https://api.example.com/save', method: 'POST', body: {data: 123}}, function (err, res) { pm.test('Success is true', () => { pm.expect(res.success).to.be.true; }); });
B. pm.sendRequest('https://api.example.com/save', 'POST', {data: 123}, function (err, res) { pm.expect(res.success).to.equal(true); });
C. pm.sendRequest({url: 'https://api.example.com/save', method: 'POST', header: {'Content-Type': 'application/json'}, body: {mode: 'raw', raw: JSON.stringify({data: 123})}}, function (err, res) { pm.test('Success is true', () => { pm.expect(res.json().success).to.be.true; }); });
D. pm.sendRequest({url: 'https://api.example.com/save', method: 'POST', body: {mode: 'formdata', formdata: {data: 123}}}, function (err, res) { pm.test('Success is true', () => { pm.expect(res.json().success).to.be.true; }); });

Solution

  1. Step 1: Check request format for JSON POST

    The correct script sets Content-Type header to application/json and sends body as raw JSON string.
  2. Step 2: Verify response test syntax

    The correct script uses res.json() to parse response and checks success field is true with valid assertion.
  3. Step 3: Compare other options

    The incorrect options use wrong argument formats, miss headers, or send formdata instead of raw JSON.
  4. Final Answer:

    pm.sendRequest({url: 'https://api.example.com/save', method: 'POST', header: {'Content-Type': 'application/json'}, body: {mode: 'raw', raw: JSON.stringify({data: 123})}}, function (err, res) { pm.test('Success is true', () => { pm.expect(res.json().success).to.be.true; }); }); -> Option C
  5. Quick Check:

    JSON POST: header + raw body + res.json().success [OK]
Hint: Set JSON header and use res.json() to test response [OK]
Common Mistakes:
  • Omitting Content-Type header for JSON
  • Sending body as plain object without raw string
  • Using wrong argument order in sendRequest
  • Testing response without parsing JSON
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard