title: Using Nodejs to make POST request to Jenkins
body: <p>I'm making a POST request after a successful GET request with NodeJS, I am getting the crumb successfully from Jenkins but I am always getting the same response from Jenkins "No valid crumb was included in the request", can someone help me where I might be missing it here?</p>
  
  <pre><code>const express = require('express');
  const bodyParser = require('body-parser');
  const app = express();
  const request = require('request');
  
  //Here we are configuring express to use body-parser as middle-ware.
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(bodyParser.json());
  
  app.get('/',function(req,res){
      res.status('404').send('Not Found');
  });
  
  app.post('/process',function(req,res){
  
  // Set the headers
  var headers = {
      '--user':       'username',
      '--password':     'password'
  }
  
  // Configure the request
  var options = {
      url: 'http://10.20.1.195:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)',
      method: 'GET',
      headers: headers
  }
  
  // Start the request
  request(options, function (error, response, body) {
      if (!error &amp;&amp; response.statusCode == 200) {
          var crumb = body; //Jenkins-Crumb:aa7d8b4c316415779703a04a99b85c50
          var headers = { crumb }
          // Configure the request
          var options = {
              url: 'http://localhost:8080/job/Nightwatch/buildWithParameters',
              method: 'POST',
              headers: headers,
              qs: {'TOKEN': 'special-token', 'PROJECT': req.body.project, 'CATEGORY': req.body.category, 'URL': req.body.staginUrl}
          }
  
          // Start the request
          request(options, function (error, response, body) {
              if (!error &amp;&amp; response.statusCode == 200) {
                  // Print out the response body
                  console.log(body)
              } else {
                  console.log(response.statusMessage)
              }
          })
  
      } else {
          console.log('Could not get crumb from Jenkins! Check NodeJS Server')
      }
  })
  
  res.end('Complete');
  });
  </code></pre>