#39284 closed defect (bug) (duplicate)
Empty REST API JSON bodies should not return an error.
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 4.7 |
| Component: | REST API | Keywords: | |
| Focuses: | Cc: |
Description
This is a follow-up to #38547. I see the need to validate JSON bodies and provide appropriate feedback if the format is invalid, but an empty body should not be invalid. There are legitimate use cases for POSTing empty bodies in a REST API, especially considering the environments that WordPress tends to run in. Empty body POSTs are valid requests, should be a valid WP REST API request.
Change History (2)
Note: See
TracTickets for help on using
tickets.
Hi @davemedema - thanks for reporting. This is already done in WordPress trunk, and this issue is a duplicate of #39150.
Note also that the error only appears in 4.7 when you send
Content-Type: application/json, so another way to avoid it is to omit the header when you send a request with an empty body.