Skip to main content
  1. Notes/
  2. Postman API Testing/

PATCH and DELETE

0xShakhawat
Author
0xShakhawat
Table of Contents

PATCH and DELETE Requests
#

This section covers using PATCH requests to update resources and DELETE requests to remove them, focusing on the Postman Library API.

Updating a Book (Checking Out)
#

The PATCH method allows partial updates to a resource. This example demonstrates updating a book’s checkedOut status.

  1. In the Postman Library API v2 collection, add a new request named “checkout a book.”
  2. Set the request method to PATCH.
  3. Set the request URL to {{baseUrl}}/books/:id.
  4. In the “Params” tab, set the id path variable to {{id}} (using the collection variable set previously).
    Setting Path Variable
  5. In the “Body” tab, select “raw” and “JSON,” then add the following JSON:
{
  "checkedOut": true
}
  1. Save and send the request.

The response should be a 200 OK with the updated book data showing checkedOut: true. The inherited collection-level authorization applies to this request.

checkedOut: true

The updated data can also be verified using the “get book by id” request.

Deleting a Book
#

The DELETE method removes a resource. This example demonstrates deleting a book.

  1. In the Postman Library API v2 collection, add a new request named “delete a book.”
  2. Set the request method to DELETE.
  3. Set the request URL to {{baseUrl}}/books/:id.
  4. In the “Params” tab, ensure the id path variable is set to {{id}}.
  5. Save and send the request.

The response should be a 204 No Content, indicating successful deletion.

Verifying Deletion
#

Sending the same request again results in a 404 Not Found error because the book with the specified ID no longer exists.

404 Response