Expected Behavior on Incorrect Keys during POST requests

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

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #28953
    Austin PassyAustin Passy
    Participant

    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>

    #28977
    Long NguyenLong Nguyen
    Moderator

    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 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.