Reputation: 4144
I'm trying to get parameters passed in the body (from a form) as DELETE request to the API as
$allVars = $request->getParsedBody();
but for some reason it will be empty when works fine for POST and PUT requests.
Any tips on that?
Upvotes: 0
Views: 497
Reputation: 4952
According to the HTTP specification a DELETE
request body should be ignored by servers since there are no "defined semantics":
A payload within a DELETE request message has no defined semantics; sending a payload body on a DELETE request might cause some existing implementations to reject the request.
It is a little bit unusual to utilize a request body for DELETE http requests. Many HTTP client libraries don't support it, so it forces a developer to construct requests from low level. Another thing, I guess that some popular web servers if use them as proxy, cut body for DELETE requests as they do for GET by default, so it requires additional configuration for them.
I would put them in the URL path or in the URL query parameters, for example:
DELETE /resource/1234
Is an entity body allowed for an HTTP DELETE request?
Upvotes: 1