Chain requests in Insomnia

Uses: Insomnia
TL;DR

Create at least two requests, send one to get a response, then configure a template tag in the second request to reuse a value from the first request’s response.

Prerequisites

Download and install Insomnia.

  1. Create a new collection.
  2. Import the KongAir Flights requests.
  3. Add the following content to the base environment:
    {
     "base_url": "https://api.kong-air.com"
    }
    

Send the first request

In the KongAir collection you configured in the prerequisites, open the Get KongAir planned flights request and click Send to get a list of flights. We can reuse content from the response in the next request.

Edit the second request

Open the Fetch more details about a flight request. This request requires a flight number in the path. We’ll use a template tag to get a flight number from the list of flights from the previous request.

Remove the _.flightNumber placeholder and start typing response in its place. When a drop-down list appears, click Response > Body Attribute.

Request URL with drop-down list to select a template tag

Configure the template tag

Click the template tag, and configure it with the following values to get the flight number for the first flight on the list:

Field

Value

Function to Perform Response
Attribute Body Attribute
Request GET Get KongAir planned flights
Filter $.[0].number
Trigger Behavior Never

Once this is done, we can see the live preview of the value (KA0284 in this example). We can then click Done to apply the changes.

Send the second request

Click Send on the Fetch more details about a flight to get the information about the first flight on the list. This is the response:

{
	"aircraft_type": "Boeing 777",
	"flight_number": "KA0284",
	"in_flight_entertainment": true,
	"meal_options": [
		"Chicken",
		"Fish",
		"Vegetarian"
	]
}
Something wrong?

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!