title: Adding User to Organization Unit and Group using Google Apps Provisioning API
body: <p>I have done coding in .Net to create google account using Google Apps Provisioning API. I am successful in creating Google Account but I am not being able to add user to particular Organization Unit and Group. I have achieved the goal of account creation like this:</p>
  
  <pre><code>//Creating Google Account
  
   AppsService appService = new AppsService("Mydomain", "AdminUsername", "AdminPassword");
  
           try
                  {
  
                  var account = appService.CreateUser(googleEmail, FirstName.Text, LastName.Text, password);
  
                  }
  
                  catch (Exception ex)
                  {
                      ResultsLabel.Text += "&lt;br /&gt;Can't create this Google Account";
                  }
  </code></pre>
  
  <p>After user is added, it gets created under main domain "Users" in Google. But I have to put that user into the Organization unit where they belong to, here in my case, I need to put the user into "Staff" Organization Unit. I am not sure what applicationName means, I am just using the project solution name or am I not using correct name here? What does applicatinName mean, and what should I use? I am using CustomerID as "GoogleCustomerId" in following code that I got from Google for our domain. I have done coding like this which doesn't work for adding user to Organization Unit:</p>
  
  <pre><code>//Adding User to Organization Unit
  
  
                  OrganizationService service = new OrganizationService("mydomain", "applicationName");
  
                  service.setUserCredentials("AdminUsername", "AdminPassword");
  
                  service.UpdateOrganizationUser("GoogleCustomerId", Email.Text, "Staff", "Users"); 
  </code></pre>
  
  <p>I get this exception with the above code to add user to Organization Unit:</p>
  
  <pre><code>Google.GData.Client.GDataRequestException was unhandled by user code
    HResult=-2146233088
    Message=Execution of request failed: https://apps-apis.google.com/a/feeds/orguser/2.0/C090ll5hh/Test@domain.com
    Source=Google.GData.Client
    ResponseString=&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;AppsForYourDomainErrors&gt;
    &lt;error errorCode="1801" invalidInput="" reason="InvalidValue" /&gt;
  &lt;/AppsForYourDomainErrors&gt;
  </code></pre>
  
  <p>Here is my code to add user to Group but it is also not working, I need to add user to staff@mydomain.com group:</p>
  
  <pre><code>//Adding User to Group
  
  
     service.Groups.AddMemberToGroup("staff@mydomain.com", username);
  </code></pre>
  
  <p>Any idea on this one please?</p>
  
  <p>Thanks</p>