Information sent in DELETE body is not processed by CherryPy

28 Views Asked by At

I have this Javascript (jQuery) code:

$.ajax({
    url: `/rest/order`,
    type: 'DELETE',
    data: { "magentoid": order_id },
    success: function(data) {
    },
    error: function(xhr, status, error) {
    }
});

And when checking this call in the Chrome developer console, I can see the body is sent as well:

enter image description here

However, in my CherryPy implementation, that data seems to be completely ignored:

@cherrypy.expose
@cherrypy.tools.json_out()
def order(self, supplier = None, magentoid = None, dropship = None):
    logging.info(f"supplier: {supplier}, magid: {magentoid}")

results in:

INFO:root:supplier: None, magid: None

When I make the call in Javascript with $.post, it does work:

$.post(
    "/rest/order",
    { "magentoid": orderid, "dropship": $("#dropship").is(":checked") },
    function(data) {
    }
).fail(function() {      
});

and this shows in my CherryPy log:

INFO:root:supplier: None, magid: M13000000063

Update, also when I change DELETE into POST in the $.ajax call, the data goes away.

0

There are 0 best solutions below