Custom mime/content type

35 views
Skip to first unread message

Michael Irwin

unread,
Jun 3, 2014, 4:20:13 AM6/3/14
to res...@googlegroups.com
I'm attempting to use a custom mime type for my API.

var server = restify.createServer({
  version: require("../package.json").version,
  acceptable: ['application/vnd.api+json', 'application/json-patch+json'],
  formatters: {
    'application/vnd.api+json; q=0.9': function(req, res, body) {
      return res.formatters['application/json'](req, res, body);
    }
  }
});

I'm sending a request to the API like this:

curl -X POST -d @foo.json -H 'Content-Type: application/vnd.api+json' localhost:9000/foo

The problem is the request seems to be interpreted as something other than JSON. restify says the request body is something like:

<Buffer 7b 20 20 22 73 74 61 72 74 73 41 74 22 3a 20 22 32 30 31 34 2d 30 35 2d 31 34 54 32 32 3a 30 30 2b 30 32 3a 30 30 22 2c 20 20 22 63 75 72 72 65 6e 63 79 ...>

What am I missing?
Reply all
Reply to author
Forward
0 new messages