A. The API returns status code 200 for user with ID 1
B. The API returns a list of all users
C. The API creates a new user
D. The API returns status code 404 for user with ID 1
Solution
Step 1: Analyze the HTTP method and URL
The code uses GET on endpoint /users/1, which typically fetches user with ID 1.
Step 2: Check the assertion on status code
The test expects the response status code to be 200, meaning success.
Final Answer:
The API returns status code 200 for user with ID 1 -> Option A
Quick Check:
GET /users/1 expects 200 = The API returns status code 200 for user with ID 1 [OK]
Hint: GET + statusCode(200) means successful fetch [OK]
Common Mistakes:
Thinking it creates a user (POST needed)
Assuming it fetches all users (no list endpoint)
Confusing 404 with 200 status code
4. You wrote this curl command to test an API:
curl -X GET https://api.example.com/data -d '{"id":5}'
What is wrong with this command?
medium
A. GET requests should not have a request body (-d option)
B. The URL is missing the protocol
C. The HTTP method should be POST, not GET
D. The JSON data is missing a closing brace
Solution
Step 1: Understand HTTP GET request rules
GET requests usually do not have a body; sending data with -d is ignored or causes errors.
Step 2: Check other parts of the command
The URL includes protocol https://, JSON is properly closed, and GET is valid method for fetching data.
Final Answer:
GET requests should not have a request body (-d option) -> Option A
Quick Check:
GET with body (-d) is invalid [OK]
Hint: GET requests don't send data in body (-d) [OK]
Common Mistakes:
Thinking URL lacks protocol
Assuming POST is required here
Missing JSON brace (actually present)
5. You want to automate API tests that check multiple endpoints with different HTTP methods and validate JSON responses. Which tool is best suited for this task?
hard
A. Postman manual runner
B. REST-assured
C. curl command line only
D. Browser developer tools
Solution
Step 1: Identify automation needs
Testing multiple endpoints with various HTTP methods and validating JSON requires scripting and assertions.
Step 2: Match tool capabilities
REST-assured is a Java library designed for automated API testing with rich validation support.
Step 3: Exclude less suitable tools
Postman manual runner is not fully automated, curl lacks built-in assertions, and browser tools are for debugging, not automation.
Final Answer:
REST-assured -> Option B
Quick Check:
Automated API testing with assertions = REST-assured [OK]
Hint: REST-assured = automated API tests with assertions [OK]
Common Mistakes:
Choosing Postman manual runner for automation
Using curl without assertion support
Relying on browser tools for automated tests
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.