title: Deleting contacts from a Google Apps Domain user account fails on Linux
body: <p>Using the <a href="https://code.google.com/p/google-gdata/" rel="nofollow noreferrer">google-gdata</a> client libraries I'm able to add contacs to a Google/GMail account<br>
  but when I try to delete them I get two different results based on the type of account.</p>
  
  <p>When the target account is a pure GMail account, I can delete contacts but it does not delete<br>
  all contacts in one go. Sometimes it will return a few, sometimes up to 25, even though I'm checking<br>
  if there are more contacts and looping over them.</p>
  
  <p>When the target account is a Google Apps account I simply get a timeout (after about 2 minutes)<br>
  Note that even for a Google Apps account I can add contacts.</p>
  
  <pre><code>let service = new ContactsService("ContactSync")
  service.setUserCredentials(username, password)
  
  let token = service.QueryClientLoginToken()
  service.SetAuthenticationToken(token)
  
  let uri = ContactsQuery.CreateContactsUri("default")
  let query = new ContactsQuery(uri)
  
  let rec DeleteAllGoogleContacts (query : ContactsQuery) =
      let feed = service.Query(query) : ContactsFeed
  
      feed.Entries 
      |&gt; List.ofSeq
      |&gt; List.iter(fun f -&gt; f.Delete())
  
      match feed.NextChunk with
      | x when String.IsNullOrWhiteSpace(x) -&gt; ()
      | _ -&gt; DeleteAllGoogleContacts(new ContactsQuery(feed.NextChunk)) 
  
  DeleteAllGoogleContacts(query)
  </code></pre>
  
  <p>The error for a Google Apps account is (email changed for privacy):</p>
  
  <blockquote>
    <p>Google.GData.Client.GDataRequestException: Execution of request
    failed:
    <a href="https://www.google.com/m8/feeds/contacts/email@domain.com/full/22280c0f9f627f" rel="nofollow noreferrer">https://www.google.com/m8/feeds/contacts/email@domain.com/full/22280c0f9f627f</a>
    ---> System.Net.WebException: The request timed out
     at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in :0 
     at System.Net.HttpWebRequest.GetResponse () [0x00000] in :0 
     at Google.GData.Client.GDataRequest.Execute () [0x00000] in :0 
     --- End of inner exception stack trace ---
     at Google.GData.Client.GDataRequest.Execute () [0x00000] in :0 
     at Google.GData.Client.GDataGAuthRequest.Execute (Int32 retryCounter) [0x00000] in :0 </p>
  </blockquote>
  
  <p>When <code>DeleteAllGoogleContacts</code> is first called, it will succeed in getting the feed<br>
  and the number of entries is smaller or equal to 25. The timeout occurs upon calling <code>f.Delete()</code></p>
  
  <p>Please note that, as far as I am currently aware, I cannot use OAuth here because
  this will run on a headless server with no user interaction.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>I found that there's another way to retrieve the contacts</p>
  
  <pre><code>let Delete() =
      let requestSettings = new RequestSettings("ContactSync", username, password)
      requestSettings.AutoPaging &lt;- true
  
      let contactsRequest = new ContactsRequest(requestSettings)
  
      let feed = contactsRequest.GetContacts() : Feed&lt;Contact&gt;
      feed.Entries
      |&gt; List.ofSeq
      |&gt; List.iter(fun f -&gt; contactsRequest.Delete(f))
  </code></pre>
  
  <p>This retrieves all contacts in one go, but I still get a timeout upon Delete()</p>
  
  <p><strong>Update 2:</strong></p>
  
  <p>This may actually be firewall related as I can get it to work
  from another network. If so, I'll delete the question as it is not relevant.</p>
  
  <p><strong>Update 3:</strong></p>
  
  <p>It does not seem to be caused by a firewall.<br>
  When running this on Windows with .NET everything works as expected.<br>
  When running this on Linux with the latest Mono and FSharp compiled from source,<br>
  we get the timeout exception.</p>
  
  <p>My only guess here is that it's got something to do with the SSL certificates.<br>
  For example, if you want to access the GMail SMTP on Linux you have to issue the following commands:</p>
  
  <pre><code>mozroots --import --ask-remove
  certmgr --ssl smtps://smtp.gmail.com:465
  </code></pre>
  
  <p>Otherwise it will not work. Perhaps I have to do something similar for the GData API's?</p>
  
  <p><strong>Update 4:</strong></p>
  
  <p>Looking at the endpoints for <code>Update()</code> and <code>Delete()</code>, you can see they are one and the same</p>
  
  <pre><code>https://www.google.com/m8/feeds/contacts/userEmail/full/{contactId}
  </code></pre>
  
  <p>The only difference is the HTTP verb being used: <code>PUT</code> vs <code>UPDATE</code>, and I confirmed<br>
  that Update() does work on both platforms for both targets (Windows/Linux), (GMail, Google Apps)</p>
  
  <p>The image below shows the 4 different scenarios for Delete():</p>
  
  <p><img src="https://i.stack.imgur.com/W9hQ6.png" alt="enter image description here"></p>