Last Updated On
Are you familiar with REST APIs and want to test your understanding? This post contains 25 useful REST API multiple-choice questions (quiz) to self-test your knowledge of REST API development.
1. What does API stand for in API testing?
Select the best answer
- Application Programming Interface
- Application Protocol Integration
- Automated Program Interface
- Automated Protocol Integration
2. Your API resource does no allow deletion, and a client application attempted to delete the resource. What HTTP response code should you return?
Choose one option
- 409 Conflict
- 400 Bad Request
- 406 Not Acceptable
- 405 Method Not Allowed
3. Which REST constraint specifies that knowledge and understanding obtained from one component of the API should be generally applicable elsewhere in the API?
Choose one option
- Stateless
- Uniform Interface
- Cacheable
- Client-Server
4. Which of the following HTTP Status code means FORBIDDEN, states that user is not having access to method being used for example, delete access without admin rights?
Choose one option
- 403
- 404
- 406
- 409
5. The ability to invoke a RESTful method multiple times without changing the state of the server on subsequent invocations is known as:
Choose one option
- Uniformity
- Idempotence
- Immutability
- Statefulness
6. What is REST-assured?
- a java library for testing Restful Web services
- a java api
- a resting place for API
- None
7. Which one of the following is correct?
@Test
public void test() {
given()
.when()
.get("http://dummy.restapiexample.com/api/v1/employee/2")
.then()
.statusCode(200).statusLine("HTTP/1.1 200 OK")
.body("data.employee_name", equalTo("Garrett Winters"))
.body("message", equalTo("Successfully! Record has been fetched."));
}
Options
- Response will return the details of all the employee
- Response will return the details of a specific employee
- Response will not return the status code
- Response will return message as “Garrett John”
8. Which of the following is correct for POST?
Choose one option
@Test
public void test() {
JSONObject data = new JSONObject();
data.put("employee_name", "MapTest");
data.put("profile_image", "test.png");
RestAssured
.given().contentType(ContentType.JSON).body(data.toString())
.when().post("https://dummy.restapiexample.com/api/v1/create")
.then().assertThat().statusCode(201)
.body("data.employee_name", equalTo("MapTest"))
.body("message", equalTo("Successfully! Record has been added."));
}
}
@Test
public void test() {
RestAssured
.given().contentType(ContentType.JSON).body()
.when().post("https://dummy.restapiexample.com/api/v1/create")
.then().assertThat().statusCode(200)
.body("data.employee_name", equalTo("MapTest"));
}
}
@Test
public void test() {
RestAssured
.given().contentType(ContentType.JSON).body(data.toString())
.when().post("https://dummy.restapiexample.com/api/v1/create")
.then().assertThat().statusCode(200)
.body("data.employee_name", equalTo("MapTest"));
}
}
9. Which header should be configured to tell the server XML is preferred over JSON?
Choose one option
- GET
- Accept
- User-Agent
- Content-Type
10. Which of the following is correct about web services?
Choose one option
- A web service is a collection of open protocols and standards used for exchanging data between applications or systems.
- Software applications written in various programming languages and running on various platforms can use web services to exchange data among them over computer networks like the Internet.
- Both (1) and (2)
- None of the above
11. Which of the following annotation of JAX RS API is used to annotate a method used to create/update resource?
Choose one option
- @PUT
- @POST
- @GET
- @Path
12. Which of the following annotation of JAX RS API assigns a default value to a parameter passed to method?
Choose one option
- @Context
- @DefaultValue
- @FormParam
- @CookieParam
13. Which of the following annotation of JAX RS API binds the parameter passed to method to a query parameter in path?
Choose one option
- @QueryParam
- @PathParam
- @MatrixParam
- @HeaderParam
14. Which of the below HTTP Status codes denotes NO CONTENT, such as a DELETE request or a response with no body?
Choose one option
- 200
- 201
- 204
- 304
15. Which tool can be used for automating REST API tests?
Choose one option
- Postman
- Selenium
- Jenkins
- Eclipse
16. How can you handle authentication while testing secured APIs using Postman?
Choose one option
- By passing credentials as part of request headers or body
- By disabling authentication during testing
- By hardcoding credentials directly into test scripts
- Authentication is not required for secured APIs
17. What does JSON stand for?
Choose one option
- JavaScript Object Notation
- Java Serialized Object Network
- JavaScript Oriented Networking
- Java Standardized Object Namespace
18. Which type of response format is commonly used with RESTful APIs?
Choose one option
- XML (eXtensible Markup Language)
- CSV (Comma Separated Values)
- JSON (JavaScript Object Notation)
- HTML (Hypertext Markup Language)
19. How can you pass parameters in the URL while making an API request?
- Using the request body
- Using query parameters after the question mark (?)
- By including them in the HTTP headers
- Parameters cannot be passed in the URL
20. Which type of response format is commonly used with SOAP APIs?
Choose one option
- XML (eXtensible Markup Language)
- CSV (Comma Separated Values)
- JSON (JavaScript Object Notation)
- HTML (Hypertext Markup Language)
21. What is the recommended MIME type for sending and receiving JSON over HTTP?
Choose one option
- application/json
- text/plain
- application/xml
- multipart/form-data
22. How can you validate the response status code using Rest Assured?
Choose one option
- Using the `statusCode()` method
- By comparing the response body with expected values
- By checking the response headers
- Status code validation is not supported by Rest Assured
23. How can you extract values from JSON response using Rest Assured?
Choose one option
- Using JSONPath expressions
- By parsing the entire response as text and extracting manually
- By converting JSON to XML and then extracting values
- Value extraction is not possible with Rest Assured
24. Can you perform authentication (e.g., basic authentication or OAuth2 token-based authentication) using Rest Assured?
Choose one option
- Yes
- No
25. Is it possible to write custom assertions while using Rest-Assured?
Choose one option
- Yes
- No
====================================================================
Answers
1) 1) Application Programming Interface
2) 4) 405 Method Not Allowed
3) 2) Uniform Interface
4) 1) 403
5) 2) Idempotence
6) 1) a java library for testing Restful Web services
7) 2) Response will return the details of a specific employee
8) 1)
9) 2) Accept
10) 3) Both (1) and (2)
11) 2) @POST
12) 2) @DefaultValue
13) 1) @QueryParam
14) 3) 204
15) 1) Postman
16) 1) By passing credentials as part of request headers or body
17) 1) JavaScript Object Notation.
18) 3) JSON (JavaScript Object Notation)
19) 2) Using query parameters after the question mark (?)
https://api.example.com/users?id=123&name=Vibha
20) 1) XML (eXtensible Markup Language)
21) 1) application/json
22) 1) Using the statusCode()
method
23) 1) Using JSONPath expressions
24) 1) Yes
25) 1) Yes