API REST API Testing 2 — Questions and Answers
Question 1: Which HTTP method is used to fully update an existing resource in REST?
- PATCH
- PUT (Correct answer)
- POST
- OPTIONS
Correct answer: PUT
PUT replaces the entire resource with the provided payload, making it the method for full updates.
Question 2: What is the purpose of query parameters in a REST API URL?
- Authenticate the request
- Filter or paginate results (Correct answer)
- Define the HTTP method
- Encrypt the payload
Correct answer: Filter or paginate results
Query parameters, appended after '?', are used to filter, sort, or paginate the data returned by the API.
Question 3: Which status code range represents client-side errors in REST API responses?
- 1xx
- 2xx
- 4xx (Correct answer)
- 5xx
Correct answer: 4xx
The 4xx range covers client errors, such as 400 Bad Request, 401 Unauthorized, and 404 Not Found.
Question 4: What header should a REST API client set when sending a JSON body?
- Accept: text/html
- Content-Type: application/json (Correct answer)
- Authorization: Bearer
- Cache-Control: no-store
Correct answer: Content-Type: application/json
Content-Type: application/json tells the server that the request body is formatted as JSON.
Question 5: What does it mean for a REST API to be 'stateless'?
- It never stores data
- Each request contains all information needed to process it (Correct answer)
- It uses no authentication
- It only returns static responses
Correct answer: Each request contains all information needed to process it
Statelessness means every HTTP request must carry all context needed; the server retains no client session state between calls.
Question 6: Which REST API testing assertion checks that a response arrives within an acceptable time frame?
- Schema validation
- Response time assertion (Correct answer)
- Header assertion
- Status code assertion
Correct answer: Response time assertion
A response time assertion verifies that the API replies within a defined latency threshold, ensuring performance SLAs are met.
Which HTTP method is used to fully update an existing resource in REST?