I'm trying to create content with REST, everything worked correctly until we need to an entity Reference field,I add it to my content type and in want to pass entity referenced nid to it with
Part of my code :
formValues.gender = parseInt($('input[name=optradio]:checked').val());
var postData = {};
postData.title = [{'value': formValues.name }];
postData.field_enroll_email = [{'value': formValues.email}];
postData.field_gender = [{'value': formValues.gender }];
postData.field_phone_number = [{'value': formValues.phone }];
postData.field_course_ref = [{'value': formValues.nid }];
if(formValues.ac != "") {
postData.field_academic_certificate = [{'value': formValues.ac }];
}
if(formValues.ec != "") {
postData.field_english_certificate = [{'value': formValues.ec }];
}
postData.type = 'enroll';
jQuery.ajax({
url: "/entity/node",
method: "POST",
my entity referenced machine name field is field_course_ref
and I tried following method (formValues.nid contain nid of Node that I want to referenced it )
postData.field_course_ref = [{'value': formValues.nid }];
How can I fill entity referece field with REST ?