title: How to set and get environment variables in Jmeter to test API's
body: <p>I need to set and get variables in Jmeter for API automation.</p>
  
  <p>I am using the groovy script for same.</p>
  
  <p>I have achieved same using code as below:</p>
  
  <pre><code>import org.apache.jmeter.util.JMeterUtils;
  
  JMeterUtils.setProperty("PC_CREATED_PROMO_CODE", "shubhamvalue");
  
  log.info("will it work? ="+JMeterUtils.getProperty("PC_CREATED_PROMO_CODE"))
  </code></pre>
  
  <p>Now the problem is I am not able to see the value in any contanier where I can set my hardcode values like token, baseURL, Headers. it should be similar we do in SOAP-UI or postman tests.</p>
  
  <p>Please let me know if I can see these setProperty values in file/section/container in Jmeter.</p>
  
  <p>Or suggest me any other workaround which is more feasible for same.</p>
  
  <p><a href="https://i.stack.imgur.com/yNDMn.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yNDMn.jpg" alt="enter image description here"></a></p>
  
  <p>Any workaround will be helpful and appreciated in advance.</p>