-
Notifications
You must be signed in to change notification settings - Fork 855
[SOLVED] Collection variables not working #4105
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
Comments
That is a known issue that will be fixed probably in the next release. |
Oh, awesome then! :) |
@Amer21214 As @vdespa said, these variables are not being populated in the autocomplete menus, but they do work. This has been fixed internally, and it will be out in the next release. |
Not sure if this is solved. I realize this doesn't appear correctly in the UI, but it also doesn't work with shared collections or shared documentation |
Yeah, a new version came out and it still isn't solved. It isn't a "biggy" since the Collection variables do indeed work, it's just that people who start using it will be confused (like me) and think that these variables are not being recognized. |
@Amer21214 What is the app version you are using ? |
We have fixed these issues in our Canary channel. (https://www.getpostman.com/canary). |
Aaa, it seems to be working now in the "newest new" version. Awesome!!! 👍 :) |
Awesome. |
Nevermind. I have to save the request in the collection, close the request, and then re-open it. |
This is not working in 6.2.5 . If I create a collection variable firstName and try to use it in a body as {{firstName}} postman will hang for a moment and then throw the error
|
@MikeNicholsPoints Apologies for the late reply, can you provide us with more information and possibly the code snippet? @m3dbedb |
It's not stated crear, may I ask you to change the documentation, or where I may ask for it?
|
@m3dbedb My issue was unrelated. I had a pre-request script that was trying to generate a nonce token based on the body of the POST, but it was hanging when trying to deal with the collection variables. It was user error. |
@m3dbedb Yes, we're currently actively working on improving our docs around this and I'd appreciate any feedback you have for us! We already have a ticket around improving docs for variables which you can follow here: https://github.com/postmanlabs/postman-docs/issues/1442 Thanks! |
Why are collection variables read-only? Let's say I have a collection of related API calls that all need an auth token. I have one API call that collections a new auth token and a test script that grabs that value and stores it (globally or in the environment). That's a problem for a couple of reasons. First, saving it globally is not good because often times variables like auth tokens will end up using the same name. Plus saving it globally kills the connection to the collection of related API calls. The second issue, if saving to an environment, is that I have to remember which environment goes with which collection and I have to manually select the environment each time I switch collections and workspaces. So, a couple of humble suggestions.
Thanks so much! |
I have the next issue for collection variables:
pm.variables.set("token", pm.response.json().token);
console.log(pm.variables.get("token")); |
Here is stated that |
This should be made its own new issue. I kept trying to change a collection variable until i thought postman was flaky, uninstalled and just wrote an application. |
I'm still seeing this issue on v7.2.2. This isn't fixed at all. Unless I'm missing something, but this should be really straightforward. I define a variable called |
Try removing (refreshing) your environment variables. It happened to me:
double check the declaration and using the proper settings (needed to
remove them then re add the environment.json file)
…On Mon 1. Jul 2019 at 18:15, Robert Dailey ***@***.***> wrote:
I'm still seeing this issue on v7.2.2. This isn't fixed at all. Unless I'm
missing something, but this should be really straightforward. I define a
variable called url in my collection. I do {{url}}/my/api/call in the URL
field for my request. The {{url}} shows as unresolved by Postman.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4105?email_source=notifications&email_token=ADMUVDQNFWM3MFHEI37NMCLP5IUR7A5CNFSM4ENTIHI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY6UGQY#issuecomment-507331395>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADMUVDWZ2MX4P7EMRTOBQB3P5IUR7ANCNFSM4ENTIHIQ>
.
|
What do you mean "removing/refreshing environment variables"? These are collection variables, I do not have an environment set. I'm new to Postman so if I'm missing something please let me know. |
So as me Robert, none an issue.
I wish I could show how we manage this stuff but reading a little bit of
this helped us in the past.
https://blog.getpostman.com/2017/12/29/10-tips-for-working-with-postman-variables/
Let me know if you want we can check the issue/situation directly.
Regards,
Alan
…On Mon 1. Jul 2019 at 19:22, Robert Dailey ***@***.***> wrote:
What do you mean "removing/refreshing environment variables"? These are
collection variables, I do not have an environment set. I'm new to Postman
so if I'm missing something please let me know.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4105?email_source=notifications&email_token=ADMUVDV4Q4IBYO2OMEOVOFLP5I4MTA5CNFSM4ENTIHI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY6ZQZY#issuecomment-507353191>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADMUVDXICLOIZYMY5JNRJXDP5I4MTANCNFSM4ENTIHIQ>
.
|
I have already read that article. Again I think this should be pretty straightforward. Variables work if I set them in an environment. But if I set the environment to empty/none and then set them in the Collection, it doesn't resolve the variables. |
@rcdailey I had the same issue |
I am using v7.3.3. I am facing same issue. Not able to set "token" variable in collection. It works in environment and global variable. |
Hey @rcdailey @arrk-shch Unfortunately, I have been unable to reproduce this issue. Can you provide me with some more info:
Also, if you can relate your steps to reproduce this issue, it would really help accelerate the process. |
Thanks @coditva for quick response.
|
@arrk-shch I see. The problem lies in the fact that Postman does not allow collection variables to be set with scripts. A feature request to allow this can be found here: #5053. A quick solution would be to remove the token from the collection variables and set it as a global/environment variable. |
having same issue? has it been solved? |
I'm also experiencing this problem. I have defined variables in the collection. Not even modifying in Tests. And they are not recognized nor they are sent correctly. Here is a sample collection json: {
"info": {
"_postman_id": "5e697462-e318-411a-b0e0-71174f51365e",
"name": "Sample",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Test",
"event": [
{
"listen": "prerequest",
"script": {
"id": "fc300f35-f3de-433d-be6d-72ac086a6335",
"exec": [
"console.log(pm.collectionVariables.get(\"SomeVar\"))"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "Var",
"value": "{{ SomeVar }}",
"type": "text"
}
],
"url": {
"raw": "https://localhost/test?var={{ SomeVar }}",
"protocol": "https",
"host": [
"localhost"
],
"path": [
"test"
],
"query": [
{
"key": "var",
"value": "{{ SomeVar }}"
}
]
}
},
"response": []
}
],
"variable": [
{
"id": "73a9a812-d9a4-4e85-aeae-450f66e8cee2",
"key": "SomeVar",
"value": "Test",
"type": "string"
}
],
"protocolProfileBehavior": {}
} EDIT |
I have the same problem and this is year 2020 guys, this issue not fixed on macOS release v7. *Workaround at the end of this post Below is my version screenshot if you wanted:- My problem goes back beyond 2018 it seems because someone appoint me the issue to this tread, "Unresolved Variable (not environment)".
Workaround by @adenix:
But cant Postman just 'Update' it and Users can use it on-the-fly? |
v7.29.0 collection variables not working. It picks environment variables correctly but it wont even detect the collection variables. |
@kidstell I haven't been able to reproduce this. Can you elaborate on the exact steps you took (e.g. create collection, go to edit collection, add variable, etc.)? It would also help if you can tell us the expected outcome and actual outcome that you saw. |
I am seeing the same thing. Collection Variables set in the Tests as pm.collectionVariables.set("key", "value") are null when you reference them as {{key}} in the headers or other tests. |
It now works fine after restarting the Application.
…On Fri, Jul 24, 2020 at 5:44 AM Utkarsh Maheshwari ***@***.***> wrote:
@kidstell <https://github.com/kidstell> I haven't been able to reproduce
this. Can you elaborate on the exact steps you took (e.g. create
collection, go to edit collection, add variable, etc.)? It would also help
if you can tell us the expected outcome and actual outcome that you saw.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4105 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AES2C5SQBM3R26AA6N6SGWTR5EGRVANCNFSM4ENTIHIQ>
.
|
For any Googlers who arrive here - make sure you click the Save button after adding / changing variables. Variables will not be recognized until they are saved. This is true both for Collections AND Environments. |
App Details:
Postman for Mac
Version 5.5.2
OS X 15.6.0 / x64
Issue Report:
The text was updated successfully, but these errors were encountered: