Skip to content
Tutorials Center
My learning

Topics

Lesson 29 of 30 ยท Projects and Practice

Postman and API testing interview questions

Prepare for Postman and API testing interviews: concepts, scripting, variables, CI and strategy questions with clear answers and runnable examples.

Interviewers for testing roles rarely ask you to recite a menu of Postman buttons. They want to know whether you understand what an API test proves, how you keep suites reliable, and how you decide what to test. This lesson collects the questions that come up most often, grouped by topic, with answers you can say in your own words.

Do not memorize the answers word for word. Read each question, answer it aloud, and then compare. Where an idea is easier to show than to explain, a small runnable stand-in (plain JavaScript) demonstrates it. The stand-ins model the logic, not the real product; Postman and Newman themselves cannot run on this site.

Five question areas

Concepts HTTP, REST, status codes.
Scripting pm.test, pm.expect, scripts.
Variables Scopes and chaining.
CI Newman and pipelines.

Strategy questions cut across all four.

1 / 2

Concepts

What is API testing, and how is it different from UI testing? API testing sends requests straight to the application's interface and checks the responses: status, body, headers and timing. It skips the screen, so it is faster, more stable and can reach cases the UI never allows, such as invalid input. UI tests check that the whole experience works for a person; API tests check the contract and the logic underneath. Most teams want many API tests and fewer UI tests, following the test pyramid.

What is the difference between PUT and PATCH? PUT replaces the whole resource with the body you send. PATCH changes only the fields you send. Both can be idempotent in practice, but PUT is defined as idempotent, while PATCH depends on how it is used.

What does idempotent mean? Which methods are idempotent? Repeating the same request leaves the server in the same state as sending it once. GET, PUT, DELETE, HEAD and OPTIONS are idempotent. POST is not: sending it twice usually creates two resources. The stand-in below shows the difference.

JS Idempotent PUT vs non-idempotent POST

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Which status code families do you know? 1xx informational, 2xx success (200 OK, 201 Created, 204 No Content), 3xx redirection (301, 304), 4xx client errors (400 bad request, 401 not authenticated, 403 not allowed, 404 not found, 409 conflict, 422 invalid data, 429 too many requests), 5xx server errors (500, 502, 503, 504).

401 or 403: what is the difference? 401 means the server does not know who you are (missing, expired or bad credentials). 403 means it knows who you are but you are not allowed to do this.

What are the parts of an HTTP request and response? A request has a method, a URL (with query string), headers and an optional body. A response has a status code, headers and an optional body. See HTTP and REST in ten minutes.

Postman and scripting

What is a collection, and how is it different from an environment? A collection is a folder tree of saved requests with shared auth, scripts and variables. An environment is a named set of variables, such as baseUrl and credentials for dev, staging and production. Collections say what to call; environments say where and with what values.

Where do pre-request scripts and tests run? A pre-request script runs before the request is sent, so it prepares data: a timestamp, a signature, a variable. A test script (the Tests tab) runs after the response arrives and holds pm.test assertions. Both can exist at request, folder and collection level; they run from the collection down to the request for pre-request scripts and in the same hierarchy for tests.

Write a test that checks status 200 and a field in the body.

JavaScript
// Tests tab (real Postman script, read-only here)
pm.test("status is 200", function () {
  pm.response.to.have.status(200);
});

pm.test("user has an email", function () {
  const body = pm.response.json();
  pm.expect(body.email).to.be.a("string").and.include("@");
});

What is the difference between pm.expect and pm.response.to.have...? pm.expect is the Chai assertion style for any value (pm.expect(x).to.equal(5)). The pm.response.to... helpers are shortcuts for common checks on the current response, such as status. Both throw an error when they fail, and pm.test turns that error into a failed test instead of stopping the script.

What happens when an assertion fails inside pm.test? And outside it? Inside pm.test, the failure is caught and recorded as a failed test; the rest of the script continues. An assertion outside any pm.test throws an uncaught error, which shows as a script error and is not listed as a normal test result.

The stand-in below shows that mechanism: a tiny test function catching assertion errors.

JS How pm.test turns errors into results

Press Run (or Ctrl + Enter) to see the console output here.

No output.

How do you validate a response schema? Describe the expected shape with JSON Schema and check the body against it, for example with the built-in tv4 library or Ajv inside a script. Schema checks catch missing fields and wrong types in one test. See Contract testing and OpenAPI.

Variables and chaining

Name the variable scopes and their priority. Global, collection, environment, data (from the Runner's file) and local. The most specific wins: local over data over environment over collection over global.

What is the difference between initial value and current value? The initial value is synced to Postman's cloud and shared with teammates. The current value stays on your machine. Put secrets in the current value only, so they are not shared by accident.

How do you pass a token from a login request to later requests? Save it in the login request's Tests tab, for example pm.collectionVariables.set("token", pm.response.json().token), and use {{token}} in the Authorization tab or at collection level so every request inherits it. See Chaining requests and workflows.

You see {{orderId}} literally in the Console. What went wrong? The variable was never set, was set in a different scope, or the requests ran in the wrong order. Check the earlier request's script and the variable list.

How do you run the same request with many inputs? Use the Collection Runner with a CSV or JSON data file. Each row is one iteration, and its columns become data variables such as {{qty}}. See The Collection Runner and data-driven testing.

CI and automation

What is Newman? Newman is Postman's command-line collection runner. It runs an exported collection (or one fetched by link) with an environment, prints a report and returns an exit code, so a pipeline can fail a build when tests fail.

Terminal
# Real commands, read-only here
newman run my-collection.json -e staging.json --reporters cli,junit --reporter-junit-export results.xml

What exit code does Newman return when a test fails? A non-zero code (1), which is what makes a CI job fail. Without a non-zero exit code a pipeline would stay green with failing tests.

How do you keep secrets out of a repository? Do not commit environment files with real secrets. Pass them at run time through the CI system's secret store, using environment variables or Newman's --env-var option, and keep only placeholders in the repo. See Newman, the CLI and CI/CD.

What is a monitor? A scheduled run of a collection from Postman's cloud, used to watch an API in production for failures and slowness, with alerts when tests fail.

Strategy and judgment

How do you decide what to test in an API? Start from risk and the contract. For each endpoint cover the happy path, required and optional fields, boundary values, invalid and missing input, authentication and authorization, and error responses. Add checks for pagination, filtering and idempotency where they apply. Skip testing the framework or the database engine themselves.

The stand-in below generates boundary values for a numeric field, a technique interviewers like to hear about.

JS Boundary values for a field that accepts 1 to 100

Press Run (or Ctrl + Enter) to see the console output here.

No output.

What makes an API test flaky, and how do you fix it? Common causes are shared test data that other tests change, tests that depend on each other's order, fixed delays instead of polling, time-dependent values, and unstable third-party services. Fixes: create and delete your own data, make values unique per run, poll with a limit, freeze or compute dates, and stub external services.

How do you test an API that has no documentation? Explore it with real requests, record what you learn as saved examples, ask the developers for an OpenAPI file, and write tests for the behavior you can confirm. Treat surprises as questions for the team, not as bugs by default.

What is the difference between functional, integration and contract testing of APIs? Functional tests check one endpoint's behavior against its rules. Integration tests check that several calls or services work together. Contract tests check that provider and consumer agree on the shape of requests and responses, so a change on one side cannot silently break the other.

What security checks would you add? Calls without a token and with an expired one, accessing another user's resource by changing the id (broken object-level authorization), injection-style input, extra fields that should not be writable (mass assignment) and rate limit behavior. See Security testing basics for APIs.

How would you test performance with Postman? Use it for response-time budgets and basic monitoring. For real load (thousands of concurrent users) use a dedicated load-testing tool; a desktop collection run is not a load generator.

How to answer well

  • Say the reason, not only the fact. "I check for 401 and for 403 because they are different failures" beats "I check status codes."
  • Give a concrete example from a project or from a small practice suite such as Project: test suite for a CRUD API.
  • Admit the limits. Saying "I would use a load-testing tool for that" is a strong answer.
  • Ask a clarifying question when the scenario is vague; testers who clarify the requirement are valued.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which of these methods is NOT idempotent by definition?

    Sending POST twice usually creates two resources. GET, PUT and DELETE leave the server in the same state when repeated.
  2. 2. A request returns 401. What does it most likely mean?

    401 is about authentication. A known user who is not permitted gets 403; a missing resource gets 404; a crash is a 5xx.
  3. 3. Why put a secret in a variable's current value rather than its initial value?

    Initial values travel with the shared workspace, so secrets belong in the local current value.
  4. 4. What makes Newman useful in a pipeline?

    The exit code is what lets a CI system mark the build as failed.
  5. 5. For a field that accepts 1 to 100, which set is the best minimal boundary check?

    Bugs cluster at the edges, so test just outside and exactly on each limit.

Summary

  • Be ready to explain HTTP basics: methods, idempotency, status code families, 401 versus 403.
  • Know the Postman building blocks: collections, environments, scopes, pre-request scripts, tests and the Collection Runner.
  • pm.test records assertion failures as results instead of stopping the script.
  • Newman and exit codes connect Postman suites to CI; secrets come from the pipeline, not the repository.
  • Strategy answers should name risks, boundary values, negative cases and the limits of the tool.
  • The runnable examples here are plain JavaScript stand-ins for the ideas, not Postman itself.

Next: Postman and API testing cheat sheet.