I noticed that if an incorrect key is sent to a post or custom post type (in the meta_box object) that (in our case got removed before we finalized our Schema) a fatal error is thrown.
This happens in MB_Rest_API::update_post_meta
since rwmb_get_registry( 'field' )->get( $field_id, $object->post_type )
in the array loop is false and there for throws the error when passed to $this->update_value( $field, $value, $object->ID )
.
In the JSON spec it refers to returning an error response for invalid parameters: https://jsonapi.org/examples/#error-objects-invalid-query-parameters
Would like to discuss options, as I continue to investigate from my side as well.
The following would be the example curl (where we removed removedKey
):
curl --location --request POST 'https://wp.test/wp-json/wp/v2/customPostType' \
--header 'Accept: */*' \
--header 'Accept-Encoding: gzip, deflate, br' \
--header 'Cache-Control: no-cache' \
--header 'Connection: keep-alive' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic SOMEKEY' \
--data-raw '{
"title": "Testing",
"meta_box": {
"removedKey": true,
"requiredEquipment": [],
"recommendedEquipment": []
},
"status": "publish"
}'
<code></code>