title: NODEJS: How do I read Body Parameters with Restify?
body: <p>I'm new to Node/Restify and must be missing something stupid here, but I've been banging my head on this for awhile. Hopefully someone can help.</p>
  
  <p>I'm trying to read Body parameters from a POST request with restify. Everything I find seems to suggest that all I need is server.user(bodyParser()), but its not working and I don't know why, and I'm not really sure how to troubleshoot further. </p>
  
  <p>Can anyone help point me in the right direction on what I'm doing wrong here?</p>
  
  <p>I created a simple server like follows:</p>
  
  <pre><code>  var restify = require('restify');
  
    var server = restify.createServer();
    server.use(restify.bodyParser());
  
    server.post("/test", function(req, res){
      console.log(req.params);
      console.log(req.body);
      res.send(200);
      res.end();
    });
  
    server.listen(8081);
  </code></pre>
  
  <p>I then ran the following POST request:</p>
  
  <pre><code>POST /test?GET_PARAM=def HTTP/1.1
  Host: localhost:8081
  User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Accept-Language: en-US,en;q=0.5
  Accept-Encoding: gzip, deflate
  Connection: keep-alive
  Content-Length: 33
  
  POST_PARAM1=abc&amp;POST_PARAM2=ghi
  </code></pre>
  
  <p>This results in the following in the console:</p>
  
  <pre><code>debugger listening on port 49953
  {}
  undefined
  </code></pre>
  
  <p>If I include queryParser, I can get the GET parameters without a problem, but what I really want is the post parameters either as straight standard params (like my example), or as JSON. I've tried the request both ways.</p>
  
  <p>e.g. This gives the same response in the console:</p>
  
  <pre><code>POST /test?GET_PARAM=def HTTP/1.1
  Host: localhost:8081
  User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Accept-Language: en-US,en;q=0.5
  Accept-Encoding: gzip, deflate
  Connection: keep-alive
  Content-Length: 44
  
  { POST_PARAM1: 'abc', POST_PARAM2: 'ghi' }
  </code></pre>