creating environments and variables using Insomnia REST client

testing api's has never been easier across many environments

January 20, 2019

As a developer you often find yourself integrating with restful api's. I've been using the Insomnia REST Client for some time now. While working on a project I had a need to work with a lot of different environments. I found Insomnia to do the job and easy to use. You only need to setup a request once using variables. Then when you need to make a call to a request. You can select which environment you want the request to be made against.

Let me walk you through an example.

First thing I did was setup my environments. A development, qa and production.

Next I created the variables. Which as you can see is simply JSON syntax. In the base environment I setup every parameter I was going to need to configure per environment. I then override the parameters for each sub environment. As you can see in the dev environment I needed to override only 4 of the base variables.

Tip, you can use variables within a variable. My api_url was setup to concatenate 3 variables.

Now I setup my API's I plan to call. In the URL I use a variable so that depending on which environment is used it will call the correct URL. I also used variables for my authentication. In my case it was NTLM so I used the username and password variables I setup earlier.

Finally I'm able to make test my requests. Success! See in the timeline, the variables I had set are used in the request. Based on the environment I choose it automatically used my variables to make sure the correct api was called.

Go ahead and grab a copy of the Insomnia REST Client today. Try it out yourself, I promise it will make testing api's easier.