Postman is a popular tool used to test APIs. Follow the steps below to test your deployed API:
Open Postman: Make sure you followed section 2. Preparation Steps to download and install Postman. If you have already downloaded and installed it, open it.
Create New Request: Click Blank collection, name your new collection.
Set the URL: In the URL field, copy the Invoke URL from your deployed API Gateway. For example: https://<your-api-id>.execute-api.<region>.amazonaws.com/<stage>/<endpoint>
Select the GET method.
Paste the copied URL and add /products
.
Click Send.
Result: Display product list (currently no products)
Select the POST method.
Paste the copied URL and add /products
.
Navigate to Body, select raw and select JSON.
Fill in product information:
{
"id": "101",
"name": "Laptop Levono",
"price": "50000",
}
Click Send.
Result: Displays a message that the new product was successfully added.
{
"id": "102",
"name": "Laptop HP",
"price": "35000",
}
Select the GET method.
Paste the copied URL and add /product?id={id}
.
Click Send.
Result: Display product information by ID.
Select the PUT method.
Paste the copied URL and add /product?id={id}
.
Navigate to Body, select raw and select JSON.
Edit product information:
{
"id": "102",
"name": "Laptop HP",
"price": "35000",
}
Click Send.
Result: Displays a message that the product has been successfully updated.
Select the DELETE method.
Paste the copied URL and add /product?id={id}
.
Click Send.
Result: Displays a message that the product has been successfully deleted.