Hi,
Is it possible to assign path variables on collection level? Or do I have to set them for each individual request?
Thanks,
Max
Hi,
Is it possible to assign path variables on collection level? Or do I have to set them for each individual request?
Thanks,
Max
Hi @Max4,
From the looks of it, I dont think you can explicitly set path variables at the Collection level, nor would it make sense to, since these are request request specific.
Now, you could set the value of these path variables in the Collection level no problem, this would be just as any variable value. Then you would reference these variables as the path variable values in your requests.
I am not sure if this is what you were asking for, but its what it sounded like. If not, could you provide an example?
Best,
Orest
Hi,
My goal I figured, if I set them at collection level I they could automatically be passed down to the individual requests.
But I guess its like with Requests wontโt adopt auth-method from collection where you recommended to export the collection, write a script to change the desired items and the import it again.
Hi @Max4,
So if you want to set the path variables, each request individually would have to have its path variables defined. You could start building requests off one request, that already has a similar path variable defined, and then duplicate it, though, there would still need to be manual work done to add any additional path variables.
Given what you said, and referencing your other post, then it sounds like you want a collection level setting of path variables to be applied to all requests. Then, yes, in this case, you can also try running a script to add the path variables to each request.
Let us know if this works as well!
Hello again @odanylewycz,
It turns out that this was rather easy.
I opened the collection in Notepad++ and saw that each has an array called โpathโ where the elements which make up the path are listed. I replaced all the elements which should adopt the variable from my collection to look like โ{{element}}โ and imported the json file.
In the end the original elements from the path where replaced with the version in curly brackets which adopted the variableโs value.
I hope I was able to describe this comprehensibly.
Thanks for your input,
Max
Hi @Max4!
Thats great to hear, Iโm glad it worked, and sounded like exactly what I thought it would be.
Now if youโre curious, you can also do some of these things programmatically, as Postman has its own API that you can get Collections, Environments, etc, that look the same in the JSON format that you saw in Notepad++.
Thats where things get fun