What if you could test APIs with one click and never worry about mistakes again?
Why Send request block in Postman? - Purpose & Use Cases
Imagine you need to test an API by sending the same request over and over manually through a browser or command line.
You have to copy the URL, add headers, set the body, and hit send each time.
This manual way is slow and boring.
You might forget to add headers or use wrong data.
It's easy to make mistakes and hard to repeat exactly the same test.
Using a send request block in Postman lets you save all request details once.
Then you just run it anytime with one click or automatically in a test script.
This saves time, avoids errors, and makes testing consistent.
curl -X POST http://api.example.com/data -H 'Content-Type: application/json' -d '{"name":"test"}'
pm.sendRequest({url: 'http://api.example.com/data', method: 'POST', header: [{key: 'Content-Type', value: 'application/json'}], body: {mode: 'raw', raw: '{"name":"test"}'}}, function (err, res) { console.log(res.json()); });It enables automated, repeatable, and error-free API testing with ease.
A tester needs to check if a user registration API works correctly after every code change.
Using send request blocks, they run the same request automatically in a test suite instead of typing it manually each time.
Manual API testing is slow and error-prone.
Send request blocks save request details for easy reuse.
This makes testing faster, consistent, and less stressful.
Practice
Send request block in Postman?Solution
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.Step 2: Compare options with the purpose
Only To call APIs and test their responses automatically correctly describes calling APIs and testing responses automatically.Final Answer:
To call APIs and test their responses automatically -> Option AQuick Check:
Send request block = call and test APIs [OK]
- Confusing Send request with UI design
- Thinking it writes database queries
- Assuming it manages user accounts
Solution
Step 1: Recall correct syntax for pm.sendRequest
The correct syntax uses an object with url and method, plus a callback function.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.Final Answer:
pm.sendRequest({url: 'https://api.example.com', method: 'GET'}, callback); -> Option AQuick Check:
pm.sendRequest uses object + callback [OK]
- Passing URL and method as separate arguments
- Using wrong function names like sendRequest or pm.requestSend
- Omitting the callback function
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?Solution
Step 1: Analyze the sendRequest call and callback
The script sends a GET request and uses a callback to check the response status code.Step 2: Understand the test assertion
The test asserts that the response code equals 200, so it passes only if the API returns 200.Final Answer:
The test will pass if the API returns status 200 -> Option DQuick Check:
Test passes if res.code == 200 [OK]
- Thinking callback is missing
- Assuming syntax error without checking code
- Believing test passes regardless of response
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?Solution
Step 1: Check the sendRequest syntax
pm.sendRequest requires a callback function as the second argument to execute the request properly.Step 2: Identify missing callback
The script lacks the callback function, so the request is not sent or handled.Final Answer:
Missing callback function to handle the response -> Option BQuick Check:
sendRequest needs callback to send request [OK]
- 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
success set to true. Which Postman script correctly sends the request and tests the response?Solution
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.Step 2: Verify response test syntax
The correct script uses res.json() to parse response and checks success field is true with valid assertion.Step 3: Compare other options
The incorrect options use wrong argument formats, miss headers, or send formdata instead of raw JSON.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 CQuick Check:
JSON POST: header + raw body + res.json().success [OK]
- 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
Ready to prove it?
Pass the test and this pattern moves unknown
