Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#39284 closed defect (bug) (duplicate)

Empty REST API JSON bodies should not return an error.

Reported by: davemedema Owned by:
Priority: normal Milestone:
Component: REST API Version: 4.7
Severity: normal Keywords:
Cc: Focuses:

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
10 years ago

  • Milestone Awaiting Review
  • Resolution → duplicate
  • Status new → 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
10 years ago

Awesome, thanks @jnylen0.

Note: See TracTickets for help on using tickets.