title: Request post getting 400 status code using Node JS Express
body: <p>I have following code to post the document on a specific location. Everything is correct but somehow I am getting 400 Bad Request. Can someone suggest why this happening.</p>
  
  <p><strong>Following is my code.</strong></p>
  
  <pre><code>function storeDocuments(req, res, tokenKey, data) {
      var uniqueCode = getClientCode(req, res);
      var filePath = path.normalize(data.pdfURL);
      var boundaryKey = Math.floor(Math.random() * 1E16);
      var options = { method: 'POST',
          url: 'https://api.fundpress.io/docloader/adddocument',
          headers: {
              'content-type': 'multipart/form-data; charset=utf-8; boundary=---' + boundaryKey,
              'cache-control': 'no-cache',
              'X-KSYS-TOKEN': tokenKey
          },
          formData: {
              file: { value: fs.createReadStream(filePath),
                  options: {
                      filename: "performance_report.pdf",
                      contentType: 'application/pdf'
                  }
              },
              cultureCode: res.locals.locale,
              title: uniqueCode,
              meta: '{ "doctype":{ "value":[' + uniqueCode + '] } }',
              clientCode: uniqueCode
          }
      };
      logger.info('Making request to: ', options.url);
      request(options, function (error, response, body) {
          if (!error &amp;&amp; response.statusCode === 200) {
              logger.info('Request Completed: ', options.url, 'BODY_LENGTH: ', (body &amp;&amp; body.length));
          } else {
              if (response &amp;&amp; response.statusCode === 400) {
                  logger.warn('Upload Request failed with 400 (Bad Request), URL:', options.url);
                  logger.warn('Upload Request failed with 400 (Bad Request), BODY:', body);
                  logger.warn('Upload Request failed with 400 (Bad Request), ERROR:', error);
              } else {
                  logger.error('Upload Request error, URL:', options.url);
                  logger.error('Upload Request error, STATUS_CODE:', response &amp;&amp; response.statusCode);
                  logger.error('Upload Request error, BODY:', body);
                  logger.error('Upload Request error, ERROR:', error);
              }
          }
      });
      res.end();
  }
  </code></pre>