ethanresnick / json-api-example

An example API created with my JSON-API library (http://github.com/ethanresnick/json-api)
31 stars 15 forks source link

DELETE relationships show NOT FOUND #6

Closed futurist closed 8 years ago

futurist commented 8 years ago

with below test data:

{"links":{"self":"http://127.0.0.1:3000/organizations/5673c95ae3b3e6e54937ede1/relationships/liaisons"},"data":[{"type":"people","id":"567364ce9f62d7e72ae5f7f4"},{"type":"people","id":"567364ce9f62d7e72ae5f7f2"},{"type":"people","id":"567364ce9f62d7e72ae5f7f3"}]}

If DELETE a people from liaisons relationships, will show 404 Not Found

Code is below:

var http = require('http');

var postData = JSON.stringify(
    {"data":[ { "type": "people", "id": "567364ce9f62d7e72ae5f7f3" }] }
);

var options = {
  hostname: '127.0.0.1',
  port: 3000,
  path: '/organizations/5673c95ae3b3e6e54937ede1/relationships/liaisons',
  method: 'DELETE',
  headers: {
    'Content-Type': 'application/vnd.api+json',
    'Content-Length': postData.length
  }
};

var req = http.request(options, function(res) {})
req.write(postData);
req.end();

Is the wrong way to DELETE? or it's a bug?

ethanresnick commented 8 years ago

I don't think it's a bug in the underlying library, but it looks like the example app wasn't set up to add a route for that request. I've pushed a change that should fix the issue, but let me know if it's still happening!