Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#39284 closed defect (bug) (duplicate)

Empty REST API JSON bodies should not return an error.

Reported by: davemedema's profile davemedema 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)

#1 @jnylen0
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

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.

#2 @davemedema
9 years ago

Awesome, thanks @jnylen0.

Note: See TracTickets for help on using tickets.