Test APIs by Postman

In this step, we will test operation of the APIs using Postman tool.

Test the listing API

  1. Click + to add a new tab
  • Select GET method
  • Enter URL of the listing API that recorded from the previous step
  • Click Send

TestListAPI

  1. The returned result is the entire data of the Books table that has been processed

TestListAPI

Test the writing API

  1. Similarly create a new tab
  • Select POST method
  • Enter URL of the writing API that recorded from the previous step
  • In Body pattern, select raw
  • Copy the below text block:
{
    "id": "5",
    "rv_id": 0,
    "name": "Amazon Web Services in Action 2nd Edition",
    "author": "Andreas Wittig",
    "price": "59.99",
    "category": "IT",
    "description": "Amazon Web Services in Action, Second Edition is a comprehensive introduction to computing, storing, and networking in the AWS cloud. You'll find clear, relevant coverage of all the essential AWS services you to know, emphasizing best practices for security, high availability and scalability.",
    "image": "https://book-image-resize-store.s3.ap-southeast-2.amazonaws.com/aws.jpg"
}

TestCreateAPI

  1. Switch to Headers
  • Add KEY is Content-Type, VALUE is application/json
  • Click Send

TestCreateAPI

  1. Wait a moment, see the results returned

TestCreateAPI

  1. Open Books table in DynamoDB console to check data
  • Before call the write API

TestCreateAPI

  • After call the write API

TestCreateAPI

Test the deleting API

Since the delete Lambda function on execution deletes images uploaded by the user, we manually upload the images to the S3 bucket so the API can run properly.

  1. Open Amazon S3 console

  2. Click book-image-store bucket

TestListAPI

  1. Click Upload

TestListAPI

  1. Click Add files

TestListAPI

  1. Tải ảnh sau về máy của bạn và chọn nó để tải lên bucket

  • aws.jpg (24 ko)
  • 6. Click Upload TestListAPI

    1. After the upload is done, switch to book-image-resize-store bucket to check. This is execution result of reszie_image Lambda funtion

    TestListAPI

    1. Back to Postman, add a new tab to call the delete API
    • Select GET method
    • Enter URL of the deleting API that recorded from the previous step, replace /{id} with /5
    • Click Send

    TestListAPI

    1. Check the returned result:

    TestListAPI

    1. Open Books table in DynamoDB console to check data

    TestListAPI

    1. Open book-image-resize-store bucket to check object. The aws.jpg is deleted

    TestListAPI