ACF: Updating gallery field doesn’t work in backend

I’m assuming that $attachments_ids are the new values you want to save.

$field = get_field('images');

$attachments_ids = [
    0 => 22222,
    1 => 33333,
    2 => 44444,
    3 => 55555
];

update_field($field, $attachment_ids, $post_id);

error code: 523