Set EntryModel data on an element
To assign a related Element (i.e. related User, Category, Entry, Tag, Asset) the value should be set to an array of element ids (even if there is only one element).

public function post(UserModel $user, EntryModel $ticket, $body)
{
    $comment = new EntryModel();
    $comment-&gt;sectionId = craft()-&gt;sections-&gt;getSectionByHandle('comments')-&gt;id;

    $comment-&gt;setContent(array(
        'createdBy' =&gt; array($user-&gt;id),
        'ticket'    =&gt; array($ticket-&gt;id),
        'body'      =&gt; $body
    ));

    return craft()-&gt;entries-&gt;saveEntry($comment);
}