Bird
0
0

You want to design a REST API that allows clients to list all products and add new products. Which HTTP methods and URLs should you use?

hard📝 Application Q15 of 15
Rest API - REST API Fundamentals
You want to design a REST API that allows clients to list all products and add new products. Which HTTP methods and URLs should you use?
ADELETE /products to list, PUT /products to add new
BPOST /products to list, GET /products to add new
CPUT /products to list, DELETE /products to add new
DGET /products to list, POST /products to add new
Step-by-Step Solution
Solution:
  1. Step 1: Identify methods for listing and adding

    GET is used to retrieve or list data, POST is used to create or add new data.
  2. Step 2: Match methods with URLs

    Both actions use the /products URL; GET lists products, POST adds new products.
  3. Final Answer:

    GET /products to list, POST /products to add new -> Option D
  4. Quick Check:

    List = GET, Add = POST = A [OK]
Quick Trick: GET lists, POST adds new resources in REST APIs [OK]
Common Mistakes:
  • Swapping GET and POST roles
  • Using DELETE or PUT incorrectly
  • Confusing URLs for different actions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes