Updating token in collection

HI i have a question

in my Postman collection first API is to get token, then whole collection requires that authentication token to move forward, i wants to build a pipeline with jenkins/teamcity, but i am confused once i upload my collections to Github how it will over right the Token every-time i am running my build

is there any workaround for this ?

Hi @romy21romy and welcome here :slightly_smiling_face:

You may need to explain a bit more, is your issue with the fact that a new token will be generated every time you run your collection? In that case would you mind explaining why this is an issue?

If your question is about how to set a token and pass it forward for the other requests, you can use Environment Variables, as explained in that blog:

well my issue is i want to upload my both JSON (Collection and Environment) files to Github.
and from there i wants to call those files for my CI tool (jenkins or teamcity) using newman.

its not happening properly :frowning:

Hi @romy21romy,

This seems like you need to configure your CI tool to store the token as an environment variable, and then pull down that token each time you need to use it. This way you don’t persist the token to Github.

In terms of calling the collection with the environment, you should be able to do that with Postman API. Whatever you persist to Github will match what you already have.

You should be able to call the Postman API as well via newman.

Refer to the documentation below for how to use newman and Postman API.

https://learning.getpostman.com/docs/postman/collection-runs/command-line-integration-with-newman/

https://learning.getpostman.com/docs/postman/postman-api/intro-api/

If you would like a video to help explain, you can refer to these videos I made:

Newman

Postman API

In your collection, you can persist the token as an environment variable in a test script (using the test script), and then from there, continue using the token as a variable.

I hope this helps!
Orest