Forum Discussion

Gaetan's avatar
Gaetan
New Contributor
3 months ago

Problem with ${#Project#Token} and Environments

Hello,
In my project, i calculate a token with an API. The value of this token is send in a projet variable name Token

In my other API, i used ${#Project#Token} in my header property

When a work without Environments, it's work fine. 

But when i use an Environment, the value of my token is send to the environment variable but the ${#Project#Token} is always the oldest value (with no environment)

What's wrong in my project ?

1 Reply

  • ${#Project#Token} always reads the Project property, which never changes when you switch Environments.

    When Environments are enabled, the value you set on the Environment lives in the Environment’s Custom Properties and is accessible as ${#Env#Token}. It does not override the Project property.

    You can do one of the following:

    Use the environment scope in your header

    Authorization: Bearer ${#Env#Token}

    Write the token into the Project property as well (so your existing ${#Project#Token} keeps working):

    def proj = context.testCase.testSuite.project proj.setPropertyValue('Token', newToken)

    // if you also keep an env value:

    proj.getActiveEnvironment()?.setPropertyValue('Token', newToken)

    • Or auto-sync after you fetch the token
      Add a Property Transfer (or a Groovy step) that copies Env.Token -> Project.Token.

    Let me know if that helps!