Programatically save node fields if fields is autocomplete? I have created a content type with 3 fields and my one field is node_refrence in this filed I am filling title of other node using node_refrence.

I am using this code.

&gt; $node = new stdClass(); 
 $node-&gt;type = 'application';
&gt; node_object_prepare($node);
&gt; $node-&gt;title = "test title";
 $node-&gt;language = LANGUAGE_NONE;
&gt; $node-&gt;field_application_school[$node-&gt;language][]['target_id']  =
&gt; 1373;
&gt; $node-&gt;field_application_school[$node-&gt;language][]['target_type'] =
"node";
 node_save($node);


I need to  fill the entry  for $node-&gt;field_application_school[$node-&gt;language][]['target_id'], its not working.
@jsh I'd suggest to create a test node through the admin menu (i.e. node/add/content_type) then dpm/debug the $node object in that content type template and finally view the node and look through the object's output and see where your code differs from the object constructed by Drupal.