Data: Error on Delete 204: XML Parsing Error: no root element found

Created on 29 Oct 2016  路  3Comments  路  Source: emberjs/data

I am using the JSONAPIAdapter against a node/express server via an Ember Proxy. I am following the JSON API spec and returning a 204 No Content response. The record is successfully deleted on the server and in the Ember Data model.

http://jsonapi.org/format/#crud-deleting

Here is the EmberJS code:

delete: function(id) {

  console.log('deleting org with id [' + id + ']');

  this.get('store').findRecord('organization', id, { backgroundReload: false })
    .then(function(data) {

      data.destroyRecord().then(function(){
        console.log('Successfully deleted record');
      });

    });

}

In my console I am getting this error:

deleting org with id [bde4b1c7-5941-f6a2-ceea-73eef4220701] web.js:395:9
Successfully deleted record web.js:400:13
XML Parsing Error: no root element found
Location: http://localhost:4200/api/organizations/bde4b1c7-5941-f6a2-ceea-73eef4220701
Line Number 1, Column 1: bde4b1c7-5941-f6a2-ceea-73eef4220701:1:1

I have tried inserting an empty JSON object {} into the response but I still get this message.

Needs Bug Verification

Most helpful comment

Make sure send an empty JSON object as a response from nodejs api on successful deletion of record.
i.e

Use res.send({}); instead of res.send();

All 3 comments

XML Parsing Error: no root element found looks weird, is the Content-Type: application/vnd.api+json set correctly in your server?

Would you be able to create a reproduction of this error? Here's a good template with Pretender.js included.

As I was testing this it seems as though the only place this error occurs is in Firefox. Chrome and Edge have zero issues with this call.

To be honest, I expected that Firefox would have a more mature developer toolset and assumed that the fault lay in Ember Data. Silly me.

Closing the issue.

Make sure send an empty JSON object as a response from nodejs api on successful deletion of record.
i.e

Use res.send({}); instead of res.send();

Was this page helpful?
0 / 5 - 0 ratings