Create a cloud-hosted mock server in Insomnia
In your Insomnia project, click Create > Mock Server, then enter a name, select Cloud Mock and click Create. Once the server is created, click New Mock Route and configure the route.
Create the mock server
In your Insomnia project, click Create > Mock Server. In the dialog box, enter a name for the server, select Cloud Mock, and click Create.
The mock server opens and you can start adding routes.
Create a route
In this example, we want to create a /flights
route based on the KongAir Flights specification.
- In your mock server, click New Mock Route, enter the path, and click Create. Once this is done, you can click Show URL to see the mock URL.
- Select the method. In this example, we’ll keep the default
GET
. - Add the response body example from the specification:
[ { "number": "KD924", "route_id": "LHR-SFO", "scheduled_departure": "2024-03-20T09:12:28Z", "scheduled_arrival": "2024-03-20T19:12:28Z" }, { "number": "KD925", "route_id": "SFO-LHR", "scheduled_departure": "2024-03-21T09:12:28Z", "scheduled_arrival": "2024-03-21T19:12:28Z" } ]
- Update the headers and status if needed. In this example we’ll keep the default values.
- Click Test to send a request to the mock.
You can’t define multiple responses for the same route. If you want to mock another response, you need to create a different mock server.
Validate
To validate, you can create a collection and import the requests from KongAir Flights, then create a new environment with your mock URL as the base URL. When you send the Get KongAir planned flights
request with the mock environment, you will get the response created in the mock route.