For a web API I’m developing I want to do something similar to Facebook Graph API. A user can invite another user. To accept or reject the invitation, the other user needs to do an empty POST to:
/invitation/<invitationId>/accepted
or
/invitation/<invitationId>/rejected
However, this is not working for me as, when I POST empty data, PHP (or Apache?) returns the following error:
Request entity too large!
The POST
method does not allow the data transmitted, or the data volume
exceeds the capacity limit.
Obviously this is not true since the POST data is empty (I double-checked in Firebug). So my questions are:
-
Does the HTTP protocol allow POSTing empty data? If it doesn’t I guess I’ll just post some dummy data but I’d rather avoid this kind of hack.
-
If it is allowed, how can I make Apache/PHP allow the request?
I guess that you want to do some kind of a RESTful api, and that’s why you need to send post with no data.
Apache/php should allow you to send empty post data, the restrictions must be imposed by some server configurations of the framework you are using
you can test this with this simple file:
You will see that the script detects the post request (using REQUEST_METHOD from the _SERVER superglobal) even if the _POST array is empy