title: Postman Get Request Set Environment Variable
body: <p>I have a <code>GET</code> request in Postman. I am trying to set an Environment Variable for <code>objectId</code> from the response body.</p>
  
  <p>Here is my response body which is fine.</p>
  
  <pre><code>{
  
    "odata.metadata": "https://graph.windows.net/myorganization/$metadata#directoryObjects/Microsoft.DirectoryServices.User",
  
      "value": [
  
      {
  
          "odata.type": "Microsoft.DirectoryServices.User",
  
          "objectType": "User",
  
          "objectId": "0fjrkfkfc-50b1-4259-a778-sjvmfgr5bhjj",          
     }
          ]
  }
  </code></pre>
  
  <p>I have tried the following to save the objectId as an Environment Variable but its not working.  Any help will be appreciated.</p>
  
  <pre><code>var jsonData = JSON.parse(responseBody);
  postman.setEnvironmentVariable("testtoken", jsonData.value[1]);  // returns [object Object]
  postman.setEnvironmentVariable("testtoken", jsonData.odata.metadata); // returns [object Object]
  postman.setEnvironmentVariable("testtoken", jsonData.value);  // returns [object Object],[object Object],[object Object], etc.
  postman.setEnvironmentVariable("testtoken", jsonData.odata.metadata.value);  // returns nothing
  postman.setEnvironmentVariable("testtoken", jsonData.odata.metadata.value.objectId);  // returns nothing
  </code></pre>