-
Notifications
You must be signed in to change notification settings - Fork 2k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Per-request Variables #203
Comments
I agree, this would be very useful. I'd like to be able to enter placeholders in the query parameters. When you submit a request, if the parameters have placeholders, it should automatically display a dialog for the user to input the values for the specific request. This would be much more elegant than manually editing the values in the query fields each time you submit a request. |
Another example of how this would be useful... I'm working with a URL format in which the just the parameter value is appended to the URL, without the parameter name. For instance: https://www.xzy.com/path/to/api/123 Presently, there's no way to automatically build this format in the query tab. I can manually insert a placeholder in the URL, but then I'd have to manually edit the environment each time I want to use a different value. If we had the ability to create per-request variables, then I could insert the placeholder in the URL and it would prompt me for the value each time I submit the request. |
So after reflecting on this a bit more, I'm thinking these placeholders should insert raw values, exactly as entered by the user, not a key/value input like in the Query tab. That would give us the flexibility to enter formats like the one I described, without Insomnia messing it up by trying to turn it into a standard query string key/value pair. Another approach would be to allow the user to select the format on a per-line basis in the Query tab and also in this new per-request tab I'm proposing. You could have a little toggle switch next to each item, to allow the user to select whether the variable will be inserted in raw format or in key/value format. |
Definitely it should not be limited to query string key/value pairs. @bkonia, if I'm understanding you correctly, you would want something like this:
And then in the "placeholders" tab there would be a list of key/value pairs:
This would work for me. However since I would frequently want to edit both query parameters and placeholders for the same request, it would be nice to have them both on the same tab, maybe in a split screen. |
Yeah, that's correct. |
Here's a wacky idea: how about being able to switch between sets of parameters and query key/value pairs for a single request? Maybe even keep a history of them? |
I was also looking for something like the Query tab, but for Path parameters. |
I agree, per-request variables would be great. We generate all of our services on the fly and because of that we needed a way of testing those calls so we created a generator for Insomnia as well that generates all of the requests. We seperate our requests by service and we currently store all of the variables for all of the requests in the environment overrides on a folder level but we would really like to be able to use different values for each of the calls even if they happen to have the same name for parameters. Screenshots below for visual on our setup. |
Definitely great feature! It would be good to have it. |
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. |
Thumbs up for this feature. Would be much appreciated. |
Thumbs up for this feature as well. Would love to have this. |
Chimed in so that stale bot won't mark this as stale again. |
I'd like to see an window of key value pairs for all the variables used in the request including this new concept of pre-request variables. This would give you the option to override any variable for the request but reset when you are done with the session. |
As already stated in this thread, having a dialog window open when the request is made to fill out any placeholder variables would be a much appreciated feature! Another idea would be to have these variables stored in a tab on the request much like headers and other fields to avoid opening the dialog every new request. In that sense the user only has to interact if they are missing. Right now as a workaround I am grouping requests that use shared variables in a folder and having the folder contain shared variables as environment variables. This has the downside that every request shares the same variable while for some I would like to change that value each request (such as modifying an entry by an ID). Having the possibility to change that value when I am making the request would speed things up a lot and add a lot of flexibility to how you can structure your Insomnia workflow! |
Bumping with a status update request I'm seeing multiple closed FRs and no commits or PRs mentioning this issue. How far down the line is this feature? |
Also bumping as this is an interesting feature. |
This seems to be getting a lot of traffic. I'm currently working on revamping the sync system so won't have time for a while so it might have to come from a community contribution |
|
I like the second option @ggicci mentioned in his first point. |
@brilang this wouldn't help with session level variables in a Post body though would it? You could do something similar but maybe don't limit it to variables in the Path but rather any variable that impacts the current request. |
There could be an url parameters table right above the query parameters table in the same Query tab. |
Is there any progress in this feature? |
2020 and still not a sign of this feature :( I guess I have to use postman untill this becomes a thing :( |
I need this feature because I want to solve the encoding problem |
I think this feature would be awesome, please consider it. thanks for all the hard work |
It seems there is already a plugin available: https://insomnia.rest/plugins/insomnia-plugin-path-parameters |
Yeah, the insomnia-plugin-path-parameters is the "best" solution so far. However, it is not completely integrated in the app. For example, the url preview in the Query tab is incorrect. About the template tag, I find this feature not that practical since you are prompted for each and every prompt variable that needs to be resolved when a request is sent. Otherwise, a "path params" or "request variable" tab would probably do the job. |
I see the path params like env variables but to request level. I think I could define path params in my env variables but need to replace for some tests in specific requests..so I see as another layer of env variables but with the highest priority |
The contribution guidelines seem pretty normal, I see no reason you shouldn't PR it! On behalf of everyone else watching this issue and hoping for this feature, I appreciate the effort! I will say though that there is already a way to specify placeholders with ctrl+space for environment variables, maybe you could hook into that system? |
How cool! I'm new to Insomnia forgive me haha. I should probably add a new type of placeholder for params; I'll give that a try and keep you updated. |
Hi @Vap0r1ze! Usually it's nice to discuss and agree on a particular approach so that there is less need for rework. But, seeing as you already have something running, feel free to create a PR with some notes on your design/thought process, and we can discuss specific implementation details further. I, too, appreciate the effort! I will add that I'm not quite sure on what the best solution for this problem is yet, there are a number of valid approaches suggested here. |
Note that there's also a simple params plugin to achieve that feature, specifically https://insomnia.rest/plugins/insomnia-plugin-path-parameters |
This is the only reason why I don't use Insomnia currently. I work with a lot of restful APIs, full of parameters in the URLs. I would love to see this given the attention it deserves. <3 |
Agree. This should be a core feature. The plugin |
If you import an Open API specification, query parameters are written slightly different:
It would be great if that syntax could be supported to comply with the Open API standard. |
Yes, I don’t remember where I got that other syntax from, but the Open API syntax is correct. It should definitely be implemented as you described. |
Hi @Vap0r1ze do you have builds of your fork? I would like to use it. Without path parameters Insomnia is useless to me but I like UI. |
Is there any info about this being implemented? |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Overview
A common use-case for Insomnia is to define a set of requests up front, then only edit a small subset of values afterward (resource IDs, URL path segments, tokens, etc). This can be quite cumbersome if you need to frequently change a value inside a deep JSON structure, for example.
Solution 1 – Using placeholders
Placeholders could be defined in a request and Insomnia could detect these and provide an easy key-value editor to change/update them.
This could be done with a custom Nunjucks tag like
{% placeholder "my name" %}
, or maybe show an input for all variables that aren't defined in the currently active environment.Solution N
your idea here
The text was updated successfully, but these errors were encountered: