title: Using Node's request module to upload files via REST API
body: <p>I am using the request module for communicating with the rest API.</p>
  
  <p>So far everything was perfect, and now I have problems with uploading files.</p>
  
  <p>This is my code:</p>
  
  <pre><code>    var url = "www.targetsite.com";
      var options = {
          method: 'post',
          json: true,
          body: {
              parameter: 'param'
          },
          formData: {
              file: fs.createReadStream("pic.jpg");
          }
      }
  
      request(url, options, function(err, res, res_body){
           console.log(err);
           ...
      }
  </code></pre>
  
  <p>Here I receive the error <strong>Error: write after end</strong></p>
  
  <p>If I then remove the "json" and "body" from the options, it makes the request, and returns the error from the other side (missing parameter).</p>
  
  <p>So, how can I send both "body" and upload file in the same call?</p>