Skip to content

Restify not parsing data from a PUT method resquest, so frustrating... #521

@ezsper

Description

@ezsper

I'm using the latest version (2.6.1) of Restify, and I really don't know what is happening for the Restify not parsing the data submited on PUT/POST method, it simply doesn't make sense, Restify should be assigning the data to "req.params". I've just lost plenty of time to figured this out and I just didn't, I don't know what is going on. Is this a real issue or do I completely misunderstood the documentation?

So, I execute the follow curl command:

curl -is -X PUT -d "phone=1-800-999-9999" http://localhost:8080/note

And it just returns no params whatsoever, it must be returning the phone value submited on the curl command above:

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 4
Date: Wed, 29 Jan 2014 15:14:22 GMT
Connection: keep-alive
"{}"

This is the full code behinded, can't be more simple than this:

var restify = require('restify');
var server = restify.createServer({
  name: 'App',
  version: '1.0.0'
});
server.use(restify.acceptParser(server.acceptable));
server.use(restify.bodyParser());
server.use(restify.queryParser());
function send(req, res, next) {
  res.send(JSON.stringify(req.params));
  return next();
}
var server = restify.createServer();
server.put('/note', send);
server.listen(8080, function() {
  console.log('%s listening at %s', server.name, server.url);
});

Someone has an answer for this behavior? It really frustrating...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions