Per-request Variables #3551
-
OverviewA 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 placeholdersPlaceholders 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 Solution Nyour idea here |
Beta Was this translation helpful? Give feedback.
Replies: 63 comments 20 replies
-
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. |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
Yeah, that's correct. |
Beta Was this translation helpful? Give feedback.
-
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? |
Beta Was this translation helpful? Give feedback.
-
I was also looking for something like the Query tab, but for Path parameters. |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
Definitely great feature! It would be good to have it. |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
Thumbs up for this feature. Would be much appreciated. |
Beta Was this translation helpful? Give feedback.
-
Thumbs up for this feature as well. Would love to have this. |
Beta Was this translation helpful? Give feedback.
-
Chimed in so that stale bot won't mark this as stale again. |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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! |
Beta Was this translation helpful? Give feedback.
-
Hello there, |
Beta Was this translation helpful? Give feedback.
-
Chiming in. UPDATE: Now published https://insomnia.rest/plugins/insomnia-plugin-path-parameter-tag const pathParameterTag = {
name: "pathParam",
displayName: "Path parameter",
liveDisplayName(args) {
const name = args[0].value;
return name ? name : args[1].value;
},
description: "replace part of URI path with given value",
args: [
{
displayName: "Display name",
description: "Optional name to display instead of value in Insomnia UI. Doesn't affect the request made.",
type: "string"
}, {
displayName: "Value",
description: "Value of the path parameter",
type: "string"
}, {
displayName: "Description",
description: "Optional description of this parameter, which doesn't affect the request made",
type: "string"
}, {
displayName: "URI Encode",
description: "Select to URI encode the parameter",
type: "boolean",
defaultValue: true
}
],
async run(context, name, value, description, mustEncode) {
return mustEncode ? encodeURIComponent(value) : value;
}
};
module.exports.templateTags = [pathParameterTag]; Compared to the popular path-parameters plugin, this:
Both have the disadvantage of not being something, that an Open API import would put a placeholder for. p.s. some screenshots |
Beta Was this translation helpful? Give feedback.
-
Hello, is this discussion stil active? I remember regularly coming across this concept of "Path or URI Template" what seems to have been normalized a while ago; please check: https://en.wikipedia.org/wiki/URI_Template Cheers. |
Beta Was this translation helpful? Give feedback.
-
I guess, since gschier is no longer maintaining the project, it's up to the community to resolve the issue. Just waiting won't help :). Per-request variables are redundant and not the right solution for path parameters:
With all of that being said, I think it would make sense polishing @Vap0r1ze's PR and going with it. Edit: tried to cut down the rambling a bit. More later :D |
Beta Was this translation helpful? Give feedback.
-
Any update on this? |
Beta Was this translation helpful? Give feedback.
-
For updates on this, please refer to this comment. |
Beta Was this translation helpful? Give feedback.
-
Why isn't this a core feature of insomnia? For example path parameters are pretty common but we now having 2022 and they are still not implemented in insomnia. |
Beta Was this translation helpful? Give feedback.
-
Hi, any news on this? |
Beta Was this translation helpful? Give feedback.
-
Back to Postman because of this. 😞 Using the |
Beta Was this translation helpful? Give feedback.
-
Hello ! +1 on this feature |
Beta Was this translation helpful? Give feedback.
-
I agree with a lot of the recent comments. I recently began using Insomnia and I love everything about it but this is such an incredible oversight. Path parameters are such a standard requirement when interfacing with APIs, I was shocked to find it wasn't a feature in Insomnia. The workaround plugins are okay but it would be ideal for it to work similar to Postman where there's a dedicated tab for path parameters. It's so janky to go into the Query tab and have a disabled attribute that gets pulled into the URL. I'd be very willing to do the work and submit a PR. Is there any sentiment from the maintainers as to whether this feature would be supported? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Hello everyone, Path parameters have shipped in Insomnia 8.6 GA, available today. Now you can enter both environment variables or path parameters in the format of Here I have highlighted the areas of interest: We will be going to ship a minor 8.6.1 release sometime next week to fix some UI quirkiness, feel free to send feedback. In the minor release next week, we may also ship the ability to edit an environment variable by clicking on it, which was also part of this conversation. |
Beta Was this translation helpful? Give feedback.
-
Closing this has it has been implemented, still tracking internally the ability to enter a missing environment variable directly after submitting a request, but I consider this to be an enhancement. |
Beta Was this translation helpful? Give feedback.
-
didn't think i'd live to see the day this closes as completed, thank u devs much love 💗 |
Beta Was this translation helpful? Give feedback.
Hello everyone,
Path parameters have shipped in Insomnia 8.6 GA, available today. Now you can enter both environment variables or path parameters in the format of
:pathParam
and it will show a new section below the query parameters to value the path parameters, as discussed in this thread.Here I have highlighted the areas of interest:
We will be going to ship a minor 8.6.1 release sometime next week to fix some UI quirkiness, feel free to send feedback. In the minor release next week, we may also ship the ability to edit an environment variable by clicking on it, which was also part of this conversation.