title: Postman: Get data from JSON file in Pre-request Script
body: <p>I am trying to find a way to use data from my .json file in the pre-request script in Postman.
  As you can see in the code below I am using a loop for my request. 
  In my pre-request script i would like to use <em>"id_group":"14803,14805"</em> from my file Data.json instead of <em>id_group = ["14803","14805"];</em>.</p>
  
  <p>Thanks</p>
  
  <p><strong>URL:</strong></p>
  
  <pre><code>.../group/{{id_of_group}}/members
  </code></pre>
  
  <p><strong>Body:</strong></p>
  
  <pre><code>    {
       "id_user": {{id_user}}
      }
  </code></pre>
  
  <p><strong>Pre-request script:</strong></p>
  
  <pre><code>var id_group = pm.environment.get("id_group");
  
  if (!id_group) {
      id_group = ["14803","14805"];
  }   
  
  var currentIdGroup = id_group.shift();
  pm.environment.set("id_of_group", currentIdGroup);
  pm.environment.set("id_group", id_group);
  </code></pre>
  
  <p><strong>Tests:</strong></p>
  
  <pre><code>var id_group = pm.environment.get("id_group");
  console.log(id_group);
  if (id_group &amp;&amp; id_group.length &gt; 0) {
     postman.setNextRequest('Add user to groups');
  } else {
     postman.setNextRequest();
  }
  </code></pre>
  
  <p><strong>Data.json file:</strong></p>
  
  <pre><code>[{
   "id_user":47091,
   "id_group":"14803,14805"
  }]
  </code></pre>