Skip to content

Status Check: Add REST API endpoint #4790

@swissspidy

Description

@swissspidy

Feature Description

We're seeing reports from users where they create a story, and upon saving get greeted with error messages because saving failed due to the REST API not being available.

The problem is that they might not be saving for quite some time, so it's really frustrating to get error messages after an hour or so and potentially lose all your work.

What If upon loading of the editor/dashboard we perform some simple REST API request and see if the response is OK. If it isn't, then the REST API is likely not available, and we can display a warning message to the user.

We could probably just re-use \WP_Site_Health::get_test_rest_availability() for this. Alternatively we could do the same thing on the client-side. -> WAF detection is only possible on client-side.

Downside: this is another HTTP request that might be unnecessary for the majority of users.

Alternatives Considered

Better documentation that the REST API is required

Additional Context


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance Criteria

Implementation Brief

  • When loading dashboard/editor...
    • Create a temporary story in PHP with auto-draft status, using demo content for post_content field, just so we have a WP_Post object to work with.
    • Provide this story object via an inline script
    • On the client side, generate the story's HTML markup using getStoryMarkup()
    • Send a POST request containing this full markup to /wp-json/web-stories/v1/web-story/<id>
    • -> check status code, response content, etc. to see if this was successful or not
      Exact checks TBD

Open questions:

  • Create new web-stories/v1/status-check REST API endpoint for this?
  • Also send a GET request?

Metadata

Metadata

Assignees

Labels

Group: DashboardGroup: EditingMain editing featuresGroup: Status CheckStatus and CORS checks in the editorGroup: WordPressChanges related to WordPress or Gutenberg integrationP2Should do soonType: EnhancementNew feature or improvement of an existing feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions