Error Handling
About 1 min
The AAM RESTful API follows a design pattern similar to the WordPress core. When errors occur, a non-200 (OK) HTTP status is returned with detailed error information.
{
"code": "rest_forbidden",
"message": "Sorry, you are not allowed to do that.",
"data": {
"status": 401
}
}
Unfortunately, WordPress core has not yet fully standardized the format of error responses, which is why you may see different payloads. For example, if an authentication request fails, the response might look like this:
{
"code": "incorrect_password",
"reason": "The provided password is an invalid application password."
}
However, if a RESTful API request fails while being processed by AAM functionality, all error payloads will adhere to a similar structure:
{
"code": "rest_invalid_param",
"message": "Invalid parameter(s): type",
"data": {
"status": 400,
"params": {
"type": "type is not one of default, login_redirect, custom_message, page_redirect, url_redirect, and trigger_callback."
},
"details": {
"type": {
"code": "rest_not_in_enum",
"message": "type is not one of default, login_redirect, custom_message, page_redirect, url_redirect, and trigger_callback.",
"data": null
}
}
}
}
Error Status Codes
Below is a list of the most common error status codes that can help you identify the issue:
Code | HTTP Status Code / Description |
---|---|
rest_invalid_argument | 400. One or more input values are incorrect or missing. Refer to the official reference guide for the endpoint to identify the correct values. |
rest_unauthorized | 401. The request is unauthorized. Ensure that the user to whom the JWT token is issued has sufficient privileges to access the requested functionality. |
rest_not_found | 404. The RESTful API endpoint or the requested resource does not exist. This can occur when accessing disabled API endpoints or non-existent resources. |
rest_workflow_error | 409. The request cannot be fulfilled because it violates WordPress boundaries. For example, you cannot delete a role that has at least one user assigned to it. |
rest_unexpected_error | 500. Unexpected application errors. Check your PHP error log for more information if the error description is unclear. |
rest_insufficient_storage | 507. WordPress core failed to persist changes to the database, possibly due to insufficient server capacity. This error may occur occasionally. |