title: Using postman.setNextRequest() to populate request body before Send
body: <p>I have a postman collection with two requests.</p>
  
  <ul>
  <li>POST <code>/make-request</code></li>
  <li>GET <code>/prepare-request</code></li>
  </ul>
  
  <p>The body of <code>/make-request</code> has a variable in it like so.</p>
  
  <pre><code>{
    "key": {{key}}
  }
  </code></pre>
  
  <p>The <code>Tests</code> tab of the <code>/prepare-request</code> takes it's response JSON body and puts sets <code>data.key</code> as a global variable <code>key</code> in postman like this.</p>
  
  <pre><code>var data = JSON.parse(responseBody);
  postman.setGlobalVariable("key", data.key);
  </code></pre>
  
  <p>Now when I <code>Send</code> the requests in this order</p>
  
  <ol>
  <li>GET <code>/prepare-request</code></li>
  <li>POST <code>/make-request</code></li>
  </ol>
  
  <p>The body of <code>/make-request</code> is populated with the response from <code>/prepare-request</code></p>
  
  <p>Now...</p>
  
  <p>What I would like to have is a <code>Pre-request Script</code> in <code>/make-request</code> that runs <code>/prepare-request</code> before and automatically populates the body of <code>/make-request</code> every time, before it runs. I've tried this, but it doesn't work.</p>
  
  <pre><code>postman.setNextRequest("/prepare-request")
  </code></pre>
  
  <p>Thoughts? Is this the correct usage of <code>.setNextRequest()</code>. Is there anyway I can get this functionality our of postman and <a href="https://github.com/postmanlabs/newman" rel="nofollow">newman</a>.</p>