Basic usage of Insomnia

Insomnia

It’s an API design platform like postman. Most function, except Sync, is free.

1.Download

Insomnia

2.Basic Usage

(If you already know all the buttons, just skip.)

2.1 Create new collection


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by EmmaHan20220928

Insomnia

It's an API design platform like postman. Most function, except Sync, is free.

1.Download

Insomnia

2.Basic Usage

(If you already know all the buttons, just skip.)

2.1 Create new collection

Insomnia app

2.2 Create new folder and http request

In new collesction

2.3 Folder settings

Right click the folder, choose settings.

In settings, you could change the folder name(F2 cannot) and click add description about the folder.

All the description will show in the final export document.

Right click the folder

Setting image

2.4 Request Area

JSON: request body. could choose any other type.
Bearer: choose token type, add value.
Query: add fields. could use [gt] to filter data
Header: request header.
Doc: single request document

Request area

2.5 Add Environment

Click add button beside Sub Environments.

Add environment variable in the right area.

Caution: every field and value must be wrapped in "", including the Insomnia variable(will be mentioned later).

button

Environment management

3 Common scenario

Doesn't like postman, Insomnia can only use build in method or plugins.

3.1 Reuse a token from login request

Scenario description:

1) Login response body will contain a token;
2) You need the token to make other requests;

Login image

Steps to follow:

1) Open the environment, create a token variable.

In value, type a 'r'(or any other character, wait a second, Insomnia will show a list to choose from) and choose 'Response => Body Attribute'.

2) Click the 'Response => Body Attribute', config the method in 'Edit Tag'.

3) It used JSONPath to filter token.

4) Refer the variable in the headers. Type 't' and it will show the variable list.

Environment variable

Method config

Request Image

3.2Reuse token from cookie

Scenario description:

1) Using cookie to send and receive token.

As shown in the login request image.

2) request send token prefix with bear.

Login request

Steps to follow:

1) Choose 'Bearer', type in cookie and click it to config.

2) Choose your url and type in cookie name and then you can copy it to any request you want.

Cookie

Cookie manage

4 Create Document

I only find the way using command line, don't know if there is other.

Reference doc

To follow the steps, you need to download insomnia-documenter first.

  1. Click the collection and choose 'import/export'.
  2. Choose current project in 'Export data'.
  3. Choose 'Insomnia v4(JSON)' format in export.
  4. In the export folder, use 'cmd' to open the terminal and type as below. (Remember to replace 'filename' to your export filename) npx insomnia-documenter --config filename.json --output insomnia-final-result
  5. 'insomnia-final-result' is your final document. Use VScode or command line to open.

Export

Current report

Choose export request

Choose format

Document in browser

If you have better solution, please do leave comment below.

Thank you!


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by EmmaHan20220928


Print Share Comment Cite Upload Translate Updates
APA

EmmaHan20220928 | Sciencx (2022-09-29T11:29:59+00:00) Basic usage of Insomnia. Retrieved from https://www.scien.cx/2022/09/29/basic-usage-of-insomnia/

MLA
" » Basic usage of Insomnia." EmmaHan20220928 | Sciencx - Thursday September 29, 2022, https://www.scien.cx/2022/09/29/basic-usage-of-insomnia/
HARVARD
EmmaHan20220928 | Sciencx Thursday September 29, 2022 » Basic usage of Insomnia., viewed ,<https://www.scien.cx/2022/09/29/basic-usage-of-insomnia/>
VANCOUVER
EmmaHan20220928 | Sciencx - » Basic usage of Insomnia. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/09/29/basic-usage-of-insomnia/
CHICAGO
" » Basic usage of Insomnia." EmmaHan20220928 | Sciencx - Accessed . https://www.scien.cx/2022/09/29/basic-usage-of-insomnia/
IEEE
" » Basic usage of Insomnia." EmmaHan20220928 | Sciencx [Online]. Available: https://www.scien.cx/2022/09/29/basic-usage-of-insomnia/. [Accessed: ]
rf:citation
» Basic usage of Insomnia | EmmaHan20220928 | Sciencx | https://www.scien.cx/2022/09/29/basic-usage-of-insomnia/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.