Sending a Restangular DELETE or customDELETE with a body


when I hit the api with:

how can I hit the api (not from the angular app) with:


with a DELETE, everything works fine and as expected.
but When I do so from Restangular like this:"endpoint").customDELETE(idnumber,params)

I get this response from the server:

“detail”: “Unsupported media type ‘text/plain;charset=UTF-8’ in request.”

looks like the DELETE is coming with a BODY to the server, and I can’t find how to force an empty body.

(I saw this in other questions so I’ll say that in advance, yes the api is in a different port in my dev machine, and I have :

config(['$httpProvider', function($httpProvider) {
        $httpProvider.defaults.useXDomain = true;
        delete $httpProvider.defaults.headers.common['X-Requested-With'];

I like Restangular, but this problem keeps biting me. thanks!


Your problem is the content type, not that there is no body in the request. (At least I read that from your question.)

Try to define a default content type header, that should be used by Restangular as well:

RestangularProvider.setDefaultHeaders({'Content-Type': 'application/json'});

Answered By – Thomas

Answer Checked By – Timothy Miller (AngularFixing Admin)

Leave a Reply

Your email address will not be published.