title: Node JS. Send post with XML data
body: <p>I am trying to send a post request with some raw XML data. However it's not working. The code below sends no body, as if I send no data.
  Anybody has any clue how to achieve this? Tried different modules, none seemed to be able to send raw XML.</p>
  
  <pre><code>var http = require('http');
  var querystring = require('querystring');
  
  var postData = '&lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt;&lt;SearchPrices&gt;&lt;City Code="19333" /&gt;&lt;/SearchPrices&gt;';
  
  var options = {
    hostname: 'postcatcher.in',
    port: 80,
    path: '/catchers/553133a9acde130300000f08',
    method: 'POST',
    headers: {
      'Content-Type': 'application/xml',
      'Content-Length': postData.length
    }
  };
  
  var req = http.request(options, function(res) {
    console.log('STATUS: ' + res.statusCode);
    console.log('HEADERS: ' + JSON.stringify(res.headers));
    res.setEncoding('utf8');
    res.on('data', function (chunk) {
      console.log('BODY: ' + chunk);
    });
  });
  
  req.on('error', function(e) {
    console.log('problem with request: ' + e.message);
  });
  
  // write data to request body
  req.write(postData);
  req.end();
  </code></pre>
  
  <p>Ideas appreciated</p>
  
  <p>EDIT:
  Here is a PHP code that uses this service successfully. </p>
  
  <pre><code>$xml_data ='&lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt;
  &lt;SearchPrices&gt;
    &lt;City Code="19333" /&gt;
    &lt;PaxNationality Code="AR" /&gt;
    &lt;Language Code="ES" /&gt;
    &lt;CheckInDate&gt;&lt;![CDATA[2015-04-21]]&gt;&lt;/CheckInDate&gt;
    &lt;CheckOutDate&gt;&lt;![CDATA[2015-04-23]]&gt;&lt;/CheckOutDate&gt;
    &lt;IncludeRoomName /&gt;
    &lt;IncludeCancellationCharges /&gt;
    &lt;IncludePromoName /&gt;
    &lt;IncludeGeorefInfo /&gt;
  
   &lt;RoomsCriteria&gt;
      &lt;Room Number="1"&gt;
        &lt;Adults&gt;2&lt;/Adults&gt;
      &lt;/Room&gt;
  
    &lt;/RoomsCriteria&gt;
  &lt;/SearchPrices&gt;
  ';
  
  
  $URL = "URL";
  
  $ch = curl_init($URL);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_ENCODING , 1); 
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/html', 'Authorization: '.$encodeText, 'Accept-Encoding: deflate'));
  curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml_data");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $output = curl_exec($ch);
  curl_close($ch);
  
  print_r($output);
  enter code here
  </code></pre>