Search code examples
google-contacts-api

Contacts created using Google-contacts API are not getting synchronized from an Android device


I have created contacts using google contacts POST API. and I am successfully able to fetch them using GET API. Reference.

Now, Logged into the same google account from an android device and successfully synced contacts but the contacts which are created using POST API are not imported in sync.

Note:

  1. Contacts Created from Android are fetched Successfully using GET API from Web-Client.
  2. Contacts Deleted using Delete API are successfully deleted from android device on sync ( both contacts which are created using api or android) and vice-versa.

Can anyone help me by telling how to resolve this issue. Thanks in advance.


Solution

  • You have to add the gContact:groupMembershipInfo field in your XML request body while creating contacts in order to create contacts in My Contacts.

    Add the following in your POST request

    <gContact:groupMembershipInfo deleted="false" 
    href="http://www.google.com/m8/feeds/groups/userEmail/base/groupId"/>
    

    where groupId is 6 for My Contacts.

    You can get the GroupId for all the groups by sending an authorized GET request to the contact groups feed URL

    https://www.google.com/m8/feeds/groups/{userEmail}/full
    

    This request wil give the detail of the Groups.

    Refer this for more information Retrieving_all_contact_groups