I have this method in my Flask WEB API, that receive a list of IDs.
@app.route("/delete_item", methods=['DELETE'])
def delete_item():
items = request.get_json()
print(items)
my_class.delete(items)
return make_response()
When I call this method, the request.get_json() return None. I am calling it using AngularJS, as bellow:
var data = ['0', '1'. '2']
$http.delete('base_url/delete_item', {data});
How can I access the body in delete http request? The others methods (GET, PUT and POST) are working well.
the docs say:
get_json(force=False, silent=False, cache=True)
Parse data as JSON.
If the mimetype does not indicate JSON (application/json, see is_json), or parsing fails, on_json_loading_failed() is called and its return value is used as the return value. By default this raises a 415 Unsupported Media Type resp.
So from this you will either have to:
applicatation/json