title: Directory API: error updating user primaryEmail
body: <p>I'm trying to use the Directory API to change a G Suite user's account name / primary email.</p>
  
  <p>Currently the user has primary email <code>user@olddomain.com</code> and an alias <code>user@newdomain.com</code>. According to <a href="https://developers.google.com/admin-sdk/directory/v1/reference/users#resource" rel="nofollow noreferrer">the API docs</a> and the <a href="https://developers.google.com/apps-script/advanced/admin-sdk-directory" rel="nofollow noreferrer">Apps Script docs</a> I should be able to change the property <code>primaryEmail</code> using Google Apps Script.</p>
  
  <pre><code>function minimalRepro() {
    var result = AdminDirectory.Users.patch({ primaryEmail: "user@newdomain.com" }, "user@olddomain.com");
    Logger.log(result.primaryEmail);
  }
  </code></pre>
  
  <p><strong>Produces <code>error: Invalid Input: primary_user_email (line 2, file "MinimalRepro")</code>.</strong></p>
  
  <p>I've tried a number of alternatives (<code>.update</code> instead of <code>.patch</code>, using a <code>userId</code> instead of <code>user@olddomain.com</code>) and the error is the same.</p>
  
  <p>If I use <code>{ primary_user_email: XXX }</code> for the patch object instead, the code runs without error but does not update the user; <code>result.primaryEmail</code> contains the old email, and the changes never appear in the user's G Suite Profile.</p>