title: How to set the request body via Postman's pre-request script?
body: <p>I use Postman 6.0 to send an HTTP request. To send a request, I use a pre-request script to get a token and put it into the environment so that it will be used in the succeeding requests.</p>
  <p>The script below doesn't work because the body is not sent. Is there anything wrong with the script below?</p>
  <pre><code>const getTaxAccessToken={
    url: 'http://dev.xxx.com:4001/api/v1/portal/account/tax-login',
    method: &quot;post&quot;,
    body: {
        'loginIdentity': 'admic',
        'password': 'abc123'
    },
    header: {
        'Content-Type': 'application/json'
    }
  };
  pm.sendRequest(getTaxAccessToken, function (err, response) {
    console.log(&quot;get accesstoken&quot;);
    console.log(response.access_Token);
    pm.environment.set(&quot;taxAccessToken&quot;, response.access_Token);
  });
  </code></pre>