Bird
Raised Fist0
Postmantesting~10 mins

What APIs are and why testing them matters in Postman - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to send a GET request to an API endpoint using Postman scripting.

Postman
pm.sendRequest('[1]', function (err, res) {
    pm.test('Status code is 200', function () {
        pm.expect(res.code).to.eql(200);
    });
});
Drag options to blanks, or click blank then click option'
Apm.response.to.have.status(200)
Bhttps://api.example.com/data
Cpm.expect(200).to.eql(res.code)
Dconsole.log('Hello World')
Attempts:
3 left
💡 Hint
Common Mistakes
Using assertion code instead of the URL in pm.sendRequest
Putting console.log inside pm.sendRequest URL argument
2fill in blank
medium

Complete the code to check if the API response body contains the key 'success' set to true.

Postman
pm.test('Response has success true', function () {
    const jsonData = pm.response.json();
    pm.expect(jsonData.[1]).to.eql(true);
});
Drag options to blanks, or click blank then click option'
Asuccess
Bstatus
Cerror
Dmessage
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'status' or 'error' instead of 'success' key
Trying to compare the whole response instead of the key
3fill in blank
hard

Fix the error in the assertion to correctly check the response status code is 404.

Postman
pm.test('Status code is 404', function () {
    pm.expect(pm.response.code).[1](404);
});
Drag options to blanks, or click blank then click option'
Ato.eql
Bto.equal
Cto.be.eql
Dto.be.equal
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'to.equal' which is not valid in this context
Adding extra 'be' causing syntax errors
4fill in blank
hard

Fill both blanks to create a test that checks the response time is less than 200 milliseconds.

Postman
pm.test('Response time is fast', function () {
    pm.expect(pm.response.[1]).to.be.[2](200);
});
Drag options to blanks, or click blank then click option'
AresponseTime
Bstatus
Cbelow
Dabove
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'status' instead of 'responseTime' for the property
Using 'above' instead of 'below' for the assertion
5fill in blank
hard

Fill all three blanks to write a test that verifies the response JSON has a 'data' array with length greater than 0.

Postman
pm.test('Data array is not empty', function () {
    const jsonData = pm.response.json();
    pm.expect(jsonData.[1]).to.be.an('array').that.[2].length.[3](0);
});
Drag options to blanks, or click blank then click option'
Adata
Bhas
Cabove
Dincludes
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'includes' instead of 'has' for property assertion
Using 'below' instead of 'above' for length check

Practice

(1/5)
1. What is an API in simple terms?
easy
A. A programming language
B. A type of computer virus
C. A way for different software to talk to each other
D. A hardware device

Solution

  1. Step 1: Understand the role of APIs

    APIs allow different software programs to communicate and share data.
  2. Step 2: Eliminate incorrect options

    Options A, B, and D describe unrelated concepts like programming languages, viruses, or hardware.
  3. Final Answer:

    A way for different software to talk to each other -> Option C
  4. Quick Check:

    API = software communication [OK]
Hint: APIs connect software systems to share data [OK]
Common Mistakes:
  • Confusing API with programming language
  • Thinking API is hardware
  • Believing API is a virus
2. Which of the following is the correct way to send a GET request in Postman?
easy
A. Write GET in the body and click Send
B. Select GET method, enter URL, click Send
C. Select POST method, enter URL, click Send
D. Enter URL in headers and click Send

Solution

  1. Step 1: Identify the correct HTTP method usage

    GET requests are sent by selecting GET method, entering the URL, and clicking Send in Postman.
  2. Step 2: Check incorrect options

    Write GET in the body and click Send wrongly puts GET in the body; C uses POST method; D misuses headers for URL.
  3. Final Answer:

    Select GET method, enter URL, click Send -> Option B
  4. Quick Check:

    GET request = method + URL + Send [OK]
Hint: GET requests need method, URL, then Send [OK]
Common Mistakes:
  • Putting method name in body
  • Using wrong HTTP method
  • Entering URL in headers
3. In Postman, if you send a request and receive status code 404, what does it mean?
medium
A. The requested resource was not found on the server
B. The server is working fine and returned data
C. The request was successful with no content
D. The server encountered an internal error

Solution

  1. Step 1: Understand HTTP status codes

    Status code 404 means the server could not find the requested resource (page or data).
  2. Step 2: Match code to meaning

    The requested resource was not found on the server correctly describes 404; B describes success (200 OK); C is 204; D is 500 error.
  3. Final Answer:

    The requested resource was not found on the server -> Option A
  4. Quick Check:

    404 = Not Found [OK]
Hint: 404 means resource missing on server [OK]
Common Mistakes:
  • Confusing 404 with success codes
  • Thinking 404 means server error
  • Mixing 404 with no content status
4. You sent a POST request in Postman but got a 400 Bad Request error. What is the most likely cause?
medium
A. The request body is missing or malformed
B. The server is down
C. The URL is correct but method is GET
D. The response data is too large

Solution

  1. Step 1: Understand 400 Bad Request meaning

    400 error means the server could not understand the request due to bad syntax or missing data.
  2. Step 2: Identify likely cause in POST request

    POST requests usually require a body; if missing or malformed, server returns 400.
  3. Final Answer:

    The request body is missing or malformed -> Option A
  4. Quick Check:

    400 = Bad Request due to bad input [OK]
Hint: 400 error means bad or missing request data [OK]
Common Mistakes:
  • Assuming server is down for 400 error
  • Confusing method mismatch with 400
  • Thinking response size causes 400
5. Why is it important to test APIs using tools like Postman before integrating them into an application?
hard
A. To avoid writing any code in the application
B. To make the API run faster on the server
C. Because APIs never change once created
D. To ensure the API responds correctly and handles errors gracefully

Solution

  1. Step 1: Understand the purpose of API testing

    Testing APIs ensures they return correct data and handle errors well before using them in apps.
  2. Step 2: Evaluate incorrect options

    A is wrong because testing doesn't replace coding; C is false as APIs can change; D is unrelated to testing.
  3. Final Answer:

    To ensure the API responds correctly and handles errors gracefully -> Option D
  4. Quick Check:

    API testing = verify correctness and error handling [OK]
Hint: Test APIs to check responses and errors before use [OK]
Common Mistakes:
  • Thinking testing replaces coding
  • Assuming APIs never change
  • Believing testing improves server speed
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