RESTful Web APIs

RESTful Web APIs: RESTful Web APIs: an overview, Creating a REST Controller, Insomnia: GET, GET, Insomnia: POST, POST, Insomnia: PUT, PUT, Insomnia: DELETE,…

Updated

  1. RESTful Web APIs: an overview (Apprentice): REST is the standard most web APIs follow, with one HTTP verb (GET, POST, PUT, DELETE) for each CRUD operation.
  2. Creating a REST Controller (Journeyman): Build a REST API in Spring Boot with a @RestController class whose methods return JSON for each GET, POST, PUT and DELETE request.
  3. Insomnia: GET (Journeyman): Before you write the GET method, save the request you want it to answer in an Insomnia collection, with your API's address in an environment, send it, and read what comes back.
  4. GET (Journeyman): Handle a GET request in Spring Boot with @GetMapping, return the categories as JSON, and check it from Insomnia.
  5. Insomnia: POST (Journeyman): Before you write the POST method, save the request that adds a category in Insomnia, with a JSON body, send it, and learn why the answer today is 405 Method Not Allowed instead of 404.
  6. POST (Journeyman): Handle a POST request with @PostMapping and @RequestBody, insert the new category with a JdbcTemplate and return it with its generated id and a 201 status.
  7. Insomnia: PUT (Journeyman): Before you write the PUT method, save the request that changes a category in Insomnia, with the id in the address and the whole changed category in the body, and decide what it should answer.
  8. PUT (Journeyman): Handle a PUT request with @PutMapping, taking the category's id from the URL and its new values from the body, update it with a JdbcTemplate and return the updated category with a 200 status.
  9. Insomnia: DELETE (Journeyman): Before you write the DELETE method, save the request that deletes a category in Insomnia, with no body, decide what it should answer, and plan how to prove the category is gone.
  10. DELETE (Journeyman): Handle a DELETE request with @DeleteMapping, taking the category's id from the URL, and answer 204 No Content.