Test APIs by Postman

In this step, we will test the three APIs we deployed — GET, POST, and DELETE — using Postman.

Make sure you have the Invoke URLs saved from the previous steps:

  • GET / POST: https://<api-id>.execute-api.ap-southeast-1.amazonaws.com/staging/books
  • DELETE: https://<api-id>.execute-api.ap-southeast-1.amazonaws.com/staging/books/{id}

Test the GET API (List books)

  1. Open Postman. Click + to open a new tab.

    • Select the GET method.
    • Enter the Invoke URL for the listing API saved from section 4.2.
    • Click Send.

    The response body returns a JSON array containing all items from the Books DynamoDB table, including book details, image URLs, and comments. The status code is 200 OK.

    Postman - GET /books → 200 OK with JSON array

Test the POST API (Create a book)

  1. Click + to open a new tab.

    • Select the POST method.

    • Enter the Invoke URL for the writing API saved from section 4.3.

    • Click the Body tab, then select form-data.

    • Fill in the following key-value pairs. For the image key, change its type dropdown from Text to File, then select a local image file from your machine.

    • Download the image aws-logo.png at Link and select this image file.

      KeyTypeValue
      nameTextAmazon Web Services in Action 2nd Edition
      authorTextAndreas Wittig
      priceText59.99
      categoryTextIT
      descriptionTextAmazon Web Services in Action, Second Edition is a comprehensive introduction to computing, storing, and networking in the AWS cloud.
      imageFile(select a local image file, e.g., aws-logo.png)
    • Click Send. The response body returns “Successfully created item!” with status 200 OK.

    Postman - POST /books → Successfully created item!

  2. Open DynamoDB console.

    • Click Explore items → select the Books table → click Run.
    • Confirm that the new item (e.g., id = 5, author = Andreas Wittig) appears in the table. The total item count should have increased by 1 (now 10 items).

    DynamoDB - Books table with new item id=5 (10 items)

Test the DELETE API (Delete a book)

  1. Click + to open a new tab.

    • Select the DELETE method.
    • Enter the Invoke URL for the DELETE API saved from section 4.4. Replace {id} with the ID of the book you just created, e.g., 5:
      https://<api-id>.execute-api.ap-southeast-1.amazonaws.com/staging/books/5
      
    • Click Send. The response body returns “Successfully delete item!” with status 200 OK.

    Postman - DELETE /books/5 → Successfully delete item!

  2. Return to DynamoDB consoleExplore itemsBooks table → click Run again.

    • Confirm the item with id = 5 is no longer present. The total item count should have decreased by 1 (now 9 items).

    DynamoDB - Books table after deletion (9 items)

  3. Open Amazon S3 console and navigate to the book-image-resize-shop-by-tranvix bucket.

    • Confirm that the uploaded image file (aws-logo.png) has been removed. The bucket should show Objects (0).

    S3 - book-image-resize-shop-by-tranvix bucket is now empty

The book_delete Lambda function deletes both the item from DynamoDB and the associated image from the S3 resize bucket atomically. This confirms the end-to-end flow is working correctly.