REST API Testing with Postman and Newman: Fundamentals Quiz Quiz

Assess your understanding of REST API testing fundamentals using Postman and Newman. This quiz covers key concepts, terminology, and best practices related to creating, organizing, and executing API tests through automation tools.

  1. Understanding REST APIs

    Which HTTP method is commonly used to retrieve data from a REST API without modifying it?

    1. DELETE
    2. PUT
    3. GET
    4. PATCH

    Explanation: The GET method is used to request data from a REST API without making any changes to the resource. PUT and PATCH are used to update existing data, while DELETE removes data. Choosing GET is correct for safe, read-only operations.

  2. Postman Collections Essentials

    What is the main purpose of organizing API requests into a collection in Postman?

    1. To store authentication tokens only
    2. To group requests logically
    3. To create visual dashboards
    4. To encrypt API data

    Explanation: Grouping API requests into a collection helps organize related requests for easier management, sharing, and testing. Collections do not encrypt data or create dashboards directly. Storing authentication tokens is a supplementary use, not the main purpose.

  3. Request Headers

    In a scenario where an API requires a JSON payload, which header should you include in your request?

    1. Accept-Language: en-US
    2. Server: Apache
    3. Retry-After: 120
    4. Content-Type: application/json

    Explanation: Specifying 'Content-Type: application/json' informs the server that the request body contains JSON data. 'Accept-Language' relates to localization, 'Server' is a response header, and 'Retry-After' indicates when a client can retry but is not relevant for specifying payload format.

  4. Assertions in Postman

    Which feature in Postman allows you to verify that the response status code is as expected, such as 200 OK?

    1. Cookies tab
    2. Body tab
    3. Tests tab
    4. Headers tab

    Explanation: The Tests tab is where you write scripts to assert properties like the status code in API responses. The Headers and Body tabs display response data, not for assertions. The Cookies tab manages session information, not test scripts.

  5. Exporting Collections

    What file format is typically used when exporting a collection from Postman for use in Newman?

    1. CSV
    2. XML
    3. JSON
    4. TXT

    Explanation: Collections are exported in JSON format, maintaining the structure and details of requests and tests. CSV and XML formats are not used for this purpose. TXT files cannot store the necessary structured data.

  6. Running Tests with Newman

    When using Newman to run a collection, which of the following must be provided as a command line argument?

    1. The exported collection file
    2. A user manual
    3. Custom themes
    4. A password file

    Explanation: Newman requires the exported collection file as a command line argument to know which set of requests and tests to execute. User manuals, custom themes, and password files are not needed for running collections directly.

  7. Environment Variables

    Which scenario best illustrates using an environment variable in an API test collection?

    1. Naming a collection 'Production'
    2. Storing code snippets
    3. Hardcoding user passwords
    4. Setting the base URL for different servers

    Explanation: Environment variables let you switch values like the base URL easily between environments such as testing or production. Hardcoding data reduces flexibility, while storing code or naming conventions do not involve variables.

  8. Chaining Requests

    How can you use the result of one API request as input for another in a Postman collection run?

    1. By running requests separately
    2. By refreshing the tab
    3. By renaming the previous request
    4. By saving response data to a variable

    Explanation: Storing response data in variables lets you reuse information, such as an authentication token, in subsequent requests. Renaming or refreshing does not pass data forward, and running requests separately breaks the data flow.

  9. Test Result Reporting

    Which benefit does using Newman provide when integrating API tests into a continuous integration workflow?

    1. Visual project diagrams
    2. Generated command-line test reports
    3. Automatic domain registration
    4. Guaranteed zero test failures

    Explanation: Newman outputs detailed test reports in the command line or as files, which helps track results during automated workflows. It does not manage domain registration, create diagrams, or ensure zero failures—reporting is its primary contribution to automation.

  10. Handling Authentication

    If an API uses token-based authentication, which step should you include at the beginning of a test collection?

    1. Edit the API code
    2. Delete all tokens manually
    3. Send a login request to obtain a token
    4. Ignore authentication entirely

    Explanation: Sending a login request retrieves a token needed for authenticated requests. Manually deleting tokens or editing back-end code is not related to consuming an API. Ignoring authentication would result in failed requests if authentication is required.