Description
This endpoint allows you to restart the current step of the workflow for the specified entry.
Authentication
See REST API v2 Authentication.
This endpoint requires the gravityflow_admin_actions capability. This can be adjusted using gravityflow_rest_api_capability_restart_step filter.
Using the Endpoint
Path and Method
POST /gf/v2/entries/[entry_id]/workflow/steps/[step_id]/restart
The path must include the specific entry ID and current step ID that you wish to be reset.
Request Parameters
There are no required or optional properties for this endpoint.
Response
Success
A successful response will contain a JSON Workflow Status object that provides the workflow status and the current active step (if appropriate).
Failure
A failed response will provide a JSON string of the error code and message.
| Key | Type | Description |
|---|---|---|
| code | string | Error code. |
| message | string | Human-readable error message. |
| data[status] | integer | HTTP response status code |
There are several failure scenarios which could be returned depending on request data provided.
| Response Code and data[status] | Error Code | Message | Details |
|---|---|---|---|
| 401 / 403 | permission_denied | You are not allowed to start steps. | User does not have the required permissions for this endpoint. |
| 404 | entry_not_found | Invalid entry id. Entry could not be found. | Could not find an entry with the specified entry_id. |
| 404 | step_not_found | Invalid step id. Step could not be found. | Could not find a step with the specified step_id. |
| 422 | invalid_step | Step does not belong to the same form as the entry. | Step does not belong to the same form as the entry. |
| 422 | invalid_step | You can only restart the current step of a workflow. | The step_id provided is not the current for the provided entry_id. |
Examples
PHP Request
//Update these variables
$entry_id = '1273';
$step_id = '127';
$domain = 'https://develop.local';
$auth_value = 'Basic replace-me-with-basic-auth-based-on-user-application-password';
// {@see https://codex.wordpress.org/HTTP_API}
$response = wp_remote_get( $domain . '/wp-json/gravityflow/v2/entries/' . $entry_id . '/workflow/steps/' . $step_id . '/restart', array(
'headers' => array(
'Authorization' => $auth_value,
),
) );
if ( ! is_wp_error( $response ) ) {
// The request went through successfully, check the response code against
// what we're expecting
if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
// Do something with the response
// $body = wp_remote_retrieve_body( $response );
// $headers = wp_remote_retrieve_headers( $response );
} else {
// The response code was not what we were expecting, record the message
$error_message = wp_remote_retrieve_response_message( $response );
}
} else {
// There was an error making the request
$error_message = $response->get_error_message();
}
API Response
See the examples in Workflow Status object.
Since
This endpoint was added in Gravity Flow 3.0.
Source Code
This endpoint is located in the gravityflow/includes/rest-api/v2/ folder with most of the route code in the class-controller-steps.php file.