Description
This endpoint allows you to retrieve a specific step of the workflow for the specified entry.
Authentication
For details on the methods available to authenticate to the API, refer to this REST API v2 Authentication guide.
This endpoint requires the gravityflow_create_steps capability. This can be adjusted using gravityflow_rest_api_capability_get_forms_steps filter
Using the Endpoint
Path and Method
GET /wp-json/gravityflow/v2/entries/[entry_id]/workflow/steps/[step_id]
The path must include the specific entry ID and step ID that you wish to get the step details for.
Request Parameters
There are no required or optional properties for this endpoint.
Response
Success
A successful response will contain a JSON of the requested Workflow Step Object of the requested entry.
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 view 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. |
Usage
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, 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 Step Type specific examples in Workflow Step 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.