WordPress.org

Make WordPress Core

Opened 7 months ago

#48822 new enhancement

Indicate partial success/error of a REST API request

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

Description

Currently, when the REST API encounters an error, that error is typically immediately returned and any context about what processing has occurred is lost. A good example of this is creating a post.

After the post is created an error can be returned after inserting terms, meta, and additional fields. The response does not provide a way to determine the ID of the post so updates could be made to the existing post, instead you must create a new post.

As a first step, it'd be great if we could return a Link to the single item route. This is similar to the post-process link in the media endpoint except that we know there is a WP_Error instance, we don't have to always send the header. I think we'd do this by adding link support to WP_Error.

A further step might be to add a way to allow returning a partial response. For instance, if I successfully inserted a post, but just inserting some meta values failed, it'd be ideal if I could receive back the prepared item as well as the errors that were encountered. This would probably require changing the output format. We could only return the different format if the client indicated that it could process it, possibly via the Accept header.

Change History (0)

Note: See TracTickets for help on using tickets.