Custom Fields
Support MB REST API Expected Behavior on Incorrect Keys during POST requests

  • Creator
  • #28953
    Austin Passy

    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:

    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"

Viewing 1 replies (of 1 total)
  • Author
  • #28977
    Long Nguyen

    Hi Austin,

    Thank you for your feedback.

    I will inform the development team to check this case and get back to you if I have any information.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.