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.
Which HTTP method is commonly used to retrieve data from a REST API without modifying it?
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.
What is the main purpose of organizing API requests into a collection in Postman?
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.
In a scenario where an API requires a JSON payload, which header should you include in your request?
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.
Which feature in Postman allows you to verify that the response status code is as expected, such as 200 OK?
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.
What file format is typically used when exporting a collection from Postman for use in Newman?
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.
When using Newman to run a collection, which of the following must be provided as a command line argument?
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.
Which scenario best illustrates using an environment variable in an API test collection?
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.
How can you use the result of one API request as input for another in a Postman collection run?
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.
Which benefit does using Newman provide when integrating API tests into a continuous integration workflow?
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.
If an API uses token-based authentication, which step should you include at the beginning of a test collection?
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.