200-901 Question 2
Select 3A development team is building a REST API for a network automation application. They want to ensure the API adheres to proper design principles and is easy to maintain. Which of the following guidelines should they follow when designing the API?
- A
Use meaningful and consistent resource naming conventions.
- B
Always use HTTP GET for operations that modify resources.
- C
Include versioning in the API URL for backward compatibility.
- D
Return detailed error messages with proper HTTP status codes.
- E
Avoid using HTTP methods like POST and PUT for security reasons.
Show answer and explanation
Correct answers: A, C, D
Explanation
REST API design should follow principles that promote clarity, maintainability, and usability. Using proper resource naming, versioning, and meaningful error handling improves the API's usability. Misusing HTTP methods like GET for modifying resources or avoiding standard methods such as POST and PUT can lead to poor design and functionality.
- A. Correct.
Meaningful and consistent resource naming conventions ensure that the API is intuitive and easy to use.
- B. Incorrect.
Using HTTP GET for operations that modify resources violates REST principles, as GET should only be used for retrieving data and should not have side effects.
- C. Correct.
Including versioning in the API URL helps maintain backward compatibility and allows for smoother transitions when updating the API.
- D. Correct.
Returning detailed error messages and proper HTTP status codes improves debugging and ensures clients understand what went wrong.
- E. Incorrect.
Avoiding HTTP methods like POST and PUT is not a best practice; these methods are essential for creating and updating resources in REST APIs when used securely.