I'm trying to create a node on a Drupal 8 site via REST. Passing all the values to create the fields work fine apart from the field that is an entity reference field. The field is an entity reference to Drupal users. Drupal creates the node, there is no validations errors, but the entity reference field has no value. I've tried changing 'target_id' to 'value', same thing, the node gets created without errors but no value is given to the user entity reference field.
Any ideas?
$serialized_entity = json_encode([
'title' => array(
'value' => 'some_title',
),
'type' => array(
'target_id' => 'node_type',
),
'_links' => array(
'type' => array(
'href' => $base_url . '/rest/type/node/node_type',
),
),
'entity_reference_field' => array(
'target_id' => $entity_id, // This does not work. Using a valid uid.
),
'normal_field' => array(
'value' => 'some_data',
),
]);