insomnia
insomnia copied to clipboard
[Feature Request] Context menu to set environment variable
- Insomnia Version: 7.0.3.3074
- Operating System: MacOS
Details
Hello, I don't know if this has already been asked (searched a bit in the issues but didn't found something related).
It would be nice to have an option like in Postman to set an environnement variable value from a selected value in the response throught the contextual menu.
Just like in this screen (Dev
is the name of my current used environnement):
I'm using this in Postman when I'm getting a list of data and then doing an other request where I want to edit/view/use a given id as a parameter :)
I know I there is chaining request that could take data from the first request but this solution does not allow me to choose the item in the list of data that I want to use but only the first one. I should use a json path as $.data.items[0].id
.
👋 Thanks for opening your first issue! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. If you're requesting a feature 🎁, please provide real use cases that would benefit. 👪
To help make this a smooth process, please be sure you have first read the contributing guidelines.
Can you explain a bit more why chaining does not work for you? JSONPath is quite powerful so I may be able to help accomplish what you need if you provide a full example.
Sure !
I have a request where I need to pass some parameters as variables into. Those parameters are the id of others elements that I got from other requests and that I choose from their response.
In other words, I have Request 1 that send me:
{
"data": [
{
"id": "3047bde6-b8fc-4e11-acaa-ea7011585104",
...
},
{
"id": "3caffa68-fea7-4217-8704-0f29ff8af5ec",
...
},
...
]
}
And I want to take the id of the second item (for this case, but I could need to take the third for an other one) in the list as a query parameter for Request 2.
So chaining might work but I would have to go in each request using the id of Request 1 to change the index of the item I want to use.
For now, I put manually my identifiers in the environnement variables by copy/pasting them but the shortcut from Postman is quite helpfull :)
Hope you understood what I'm trying to do ^^
Thanks for that info! It's super helpful 😄
Being relatively new to Insomnia, I am not sure if I understand the above discussion correctly, but being able to specify a mapping between a response and an env variable would also be an interesting feature.
For example in the following sign-in example:
I would be happy if I could specify a permanent binding like so:
$.accessToken = myEnvAccessTokenVar
where myEnvAccessTokenVar
variable would be used for nearly all requests as Bearer auth.
This way my token would be updated no-hands after every (successful) sign-in.
Placement
A new tab in the Response pane.
Disabling
Should you need to temporarily disable a mapping, there should be a way too, via:
- a checkbox
- refer to a non-existent property:
$.---accessToken = myEnvAccessTokenVar
- add support for leading dot
.$.accessToken = myEnvAccessTokenVar
?
Indication
-
In the tab, square with the number of active mappings
-
On folders/requests with at least one active mapping there could be a subtle graphic indicator. I mean here:
That's because as your api grows, the mappings could introduce hard to discover bugs around variables, so they should be easily spotted at the folder/request listing level.
@arturhun it sounds like your use case is well suited for Request Chaining?
@gschier Maybe I am missing something, but I don't see a way to update a specific environment variable through that interface:
@arturhun you can't update one but you can use the Response tag inside an environment variable
Yup, that worked perfectly (albeit hardly discoerable) Thank you :)
Any update on this ? As the discussion drifted away a bit there was no answer to my initial question :)
@gschier Any updates ? 😄 Tell me if you need more informations as the label is still in "Need more info"
@gschier any updates ? I would be interested into this feature too.
Our team is also very interested in this specific feature.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Really? I still think this is a valuable feature to have in Insomnia...
Hi @Quelu Thank you for the suggested feature. It is not currently on our roadmap, but will be revisited at some point in the future.