DEV Community

loading...
Cover image for Quickly test your AWS API Gateway with Postman

Quickly test your AWS API Gateway with Postman

dvddpl profile image Davide de Paolis ・3 min read

As I wrote in this post and discussing about becoming a 10X Developer, I love tools that help me become more productive and allow me to avoid repetitive tasks.

Every time I have to implement or debug a RESTful API, my tool of choice is Postman: it allows you many things - like creating Mock servers and writing Test Suites - but most of the times I use it to keep a collection of APIs and quickly edit parameters/ query string / and environment variables for the different stages.

So that if a bug occurs in the client, I can quickly run the request directly in Postman and investigate the issue (especially if the request is the result of a form that is long and boring to reproduce on the client app, I just fill it once, save the payload from Chrome Dev Tools and copy it in Postman and there is no need to fiddle with Input Fields and to click hundred times around anymore).
Then I switch to different stages ( QA-TEst or DEvelopment to see if it happens there as well) and iterate changes and quick testing.

In other words, it really helps in tightening the feedback loop.

Sometimes though, it is still a bit tedious to recreate all the methods of the API and all the Collection in Postman.

Something that we do in our Team is Sharing the collection so that if someone already worked on that API, all others can benefit from his/her set up. But you can also Export your collection and pass it around or version-control it.

Just today though, I found out that you can import in Postman a Collection of your RestAPI directly exported from the Console of AWS Gateway API.

wow!

We use Serverless to describe our architecture and create our endpoint matching different Lambdas, so I rarely go to the UI Console of AWS.

This morning almost by chance I opened the console and clicked under Stages and saw that there are lots of tabs to configure the API.

One of them is named Export and clicking on it you can choose between Swagger ( another cool tool I used some years ago) and Postman Extension

Alt Text

Just click on Postman, export your json file and import it in Postman: Tadaaa! You will have everything imported nice and tidy and you can immediately start filling all the parameters you need to trigger and test your endpoints.

Alt Text

Ah. and of course, since I hate clicking around and waste time in a UI console, here you have the oneliner for the terminal.

aws apigateway get-export --parameters extensions='apigateway' --rest-api YOUR_API_ID --stage-name YOUR_STAGE --export-type swagger  YOUR_AWESOME_API_COLLETION.json

More about that here


Photo by ZACHARY STAINES on Unsplash

Discussion (0)

pic
Editor guide