title: How to get collection request name at newman cli postman
body: <p>I want to save my all response file with their request name. So I am finding a solution where I get the request name. Newman CLI is a command-line tool to run the postman collection but I read out all documentation and not get any solution for the same.</p>
  
  <pre><code>const newman = require('newman'),
  fs = require('fs');
  var envPath = "./env/POP.postman_environment.json";
  var res;
  newman.run({
      collection: require('./collection/login_HHS.postman_collection.json'),
      reporters: 'cli',
      environment:require(`${envPath}`),
      exportEnvironment: `${envPath}`
  }).on('beforeRequest', function (error, args) {
      if (error) {
          console.error(error);
      } else {
            fs.writeFile('request.txt', args.request.body.raw, function (error) {
              if (error) { 
                  console.error(error); 
              }
          });    
      }
  }).on('request', function (error,args) {
       if (error) {
          console.error(error);
      }
      else {
          console.log("args ====== "+args.response.stream)
          res = args.response.stream;
  
      }
  }).on('test', function (error, summary) {
       if (error) {
          console.error(error);
      }
      else {
          const fileName = Math.random().toString(36).substring(7) + '-foo.txt';
  
          fs.writeFile(fileName, res, function (error) {
              if (error) { 
                  console.error(error); 
              }
          });  
  
      }      
  
  });
  </code></pre>