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
2.Basic Usage
(If you already know all the buttons, just skip.)
2.1 Create new collection
2.2 Create new folder and http request
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.
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
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).
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;
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.
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.
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.
4 Create Document
I only find the way using command line, don't know if there is other.
To follow the steps, you need to download insomnia-documenter first.
- Click the collection and choose 'import/export'.
- Choose current project in 'Export data'.
- Choose 'Insomnia v4(JSON)' format in export.
- 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
- 'insomnia-final-result' is your final document. Use VScode or command line to open.
If you have better solution, please do leave comment below.
Thank you!
This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by EmmaHan20220928
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/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.