insomnia icon indicating copy to clipboard operation
insomnia copied to clipboard

[Feature Request] Context menu to set environment variable

Open Quelu opened this issue 5 years ago • 16 comments

  • 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): image

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.

Quelu avatar Nov 21 '19 10:11 Quelu

👋 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.

welcome[bot] avatar Nov 21 '19 10:11 welcome[bot]

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.

gschier avatar Nov 21 '19 16:11 gschier

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 ^^

Quelu avatar Nov 21 '19 16:11 Quelu

Thanks for that info! It's super helpful 😄

gschier avatar Dec 11 '19 16:12 gschier

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:

Screenshot 2019-12-10 at 17 45 01

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: image

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 avatar Dec 11 '19 17:12 arturhun

@arturhun it sounds like your use case is well suited for Request Chaining?

gschier avatar Dec 11 '19 17:12 gschier

@gschier Maybe I am missing something, but I don't see a way to update a specific environment variable through that interface:

image

arturhun avatar Dec 12 '19 15:12 arturhun

@arturhun you can't update one but you can use the Response tag inside an environment variable

gschier avatar Dec 13 '19 14:12 gschier

Yup, that worked perfectly (albeit hardly discoerable) Thank you :)

arturhun avatar Dec 13 '19 15:12 arturhun

Any update on this ? As the discussion drifted away a bit there was no answer to my initial question :)

Quelu avatar Feb 24 '20 07:02 Quelu

@gschier Any updates ? 😄 Tell me if you need more informations as the label is still in "Need more info"

Quelu avatar Apr 28 '20 09:04 Quelu

@gschier any updates ? I would be interested into this feature too.

micaeldekleyn avatar Jul 22 '20 14:07 micaeldekleyn

Our team is also very interested in this specific feature.

cbdelavenne avatar Nov 04 '20 18:11 cbdelavenne

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.

stale[bot] avatar May 28 '21 07:05 stale[bot]

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...

cbdelavenne avatar May 31 '21 16:05 cbdelavenne

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.

kreosus avatar Aug 24 '22 19:08 kreosus