Test APIs By Postman
In this step, we will test that the APIs work using the Postman tool. We use the sample data of the user with the id abcd1234 that was written to the Documents table in workshop 133.
When you open Postman for the first time, you may need to sign in or select a workspace before creating a new request.
Test the read API
- Click the + sign to add a new tab
- Select the GET method
- Enter the URL of the read API you noted down in the previous step:
<Invoke URL>/docs/{id}
- Replace {id} with
abcd1234
- Click Send

- The result is all the information about the files of the user with the id
abcd1234

Test the write API
- Create a new tab in the same way
- Select the POST method
- Enter the URL of the write API you noted down in the previous step:
<Invoke URL>/docs
- In the Body section, select raw and select JSON
- Copy the following:
{
"user_id": "abcd1234",
"file": "flowers.png",
"folder": "",
"identityId": "123456cvbn",
"modified": "21-03-2023",
"size": 32768,
"type": "png",
"tag": "image"
}

- Wait a moment, the result is
successfully upload!

- Open the DynamoDB console, select Explore items and select the Documents table to check the result. The Lambda function has added the path attribute and updated modified with the time the data was written.

Test the delete API
- Add a new tab to call the delete API
- Select the DELETE method
- Enter the URL of the delete data API you noted down in the previous step:
<Invoke URL>/docs/{id}, replace {id} with abcd1234
- In the Params section, enter
file for the key and flowers.png for the value
- Click Send

If you forget to enter the file parameter, the API returns a 502 Bad Gateway error because the Lambda function cannot find the name of the file to delete.
- Check that the result is
delete document successful!

- Go back to the Documents table, click Refresh to see the result
