headers – WP Rest API – Change response status code for failed validation request
Question
I have created a new route with this code:
register_rest_route(
'namespace',
'some-route',
[
'methods' => WP_REST_Server::CREATABLE,
'callback' => 'some_callback',
'args' => [
'description' => [ 'type' => 'string', 'required' => true ],
'length' => [ 'type' => 'integer', 'required' => true ],
],
]
);
It uses a built-in data validation feature. Currently, when the validation fails it sends a response with some data and the status code 400
.
How to change the built-in validation response status to 406
?
0
1 year
2022-08-07T14:22:24-05:00
2022-08-07T14:22:24-05:00 0 Answers
0 views
0
Leave an answer