-
-
Notifications
You must be signed in to change notification settings - Fork 901
Allow empty body for POST and PUT requests #781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think your solution is fine because we're talking about custom operations anyway. Yes, I myself have run into this problem too when I implemented a |
But it'd be good if we can take care of this automatically, i.e. don't try to deserialize if body is empty. Still, what if a media type attaches some meaning to an empty body? |
@teohhanhui so do you think a PR would be acceptable for this? :) |
Yes please. |
Just adding a check here should do: core/src/EventListener/DeserializeListener.php Lines 66 to 71 in f1a6537
|
closing as this has been apparently discarded! |
@kbsali I'm still ok to merge it, we just need to finish it. |
I suggest decorating the listener, like https://github.com/api-platform/docs/blob/e698aef1b147e94190dc189471b1c4b093545856/core/form-data.md (It's already possible to cleanly decorate event listeners since symfony/symfony#20207 - see discussion in symfony/symfony#19697. The documentation needs to be updated to reflect that.) |
Right now it is not possible to POST or PUT requests without specifying at least an empty object.
While this is correct for most of the use case, we've had to add a listener to bypass this for new PUT entry points we are creating which "carries" the change to be applied to our object.
eg. PUT /api/blog_posts/[id]/publish
Here is a "serious" source showing that this is perfectly fine : http://lists.w3.org/Archives/Public/ietf-http-wg/2010JulSep/0276.html :)
Do you agree? If you do, I will try to submit a PR asap, otherwise i'll live with our custom listener...
The text was updated successfully, but these errors were encountered: