google-api-java-client-services
google-api-java-client-services copied to clipboard
Question (People API) : is it still possible to manage labels (groups) using People API ?
Previously, we used to have something like this to create the labels (AKA groups) :
@WorkerThread
private fun createContactGroup(): ContactGroupEntry? {
// Create the entry to insert
try {
val newGroup = ContactGroupEntry()
newGroup.title = PlainTextConstruct(GROUP_NAME)
val additionalInfo = ExtendedProperty()
additionalInfo.name = "Temporary contacts group"
newGroup.addExtendedProperty(additionalInfo)
val postUrl = URL("https://www.google.com/m8/feeds/groups/default/full")
val group = contactsService.insert(postUrl, newGroup)
return group
} catch (ex: Exception) {
return null
}
}
And later when you wish to set it to some contacts, you could do something like that:
@WorkerThread
private fun addContactsToPeopleAPI(contactsToInsert: List<ContactEntry>,
group: ContactGroupEntry): Boolean {
try {
val requestFeed = ContactFeed()
contactsToInsert.forEach { contactEntry: ContactEntry ->
contactEntry.addUserDefinedField(
UserDefinedField("someKey","someValue"))
contactEntry.addGroupMembershipInfo(GroupMembershipInfo(false, group.id))
BatchUtils.setBatchId(contactEntry, "create")
BatchUtils.setBatchOperationType(contactEntry, BatchOperationType.INSERT)
requestFeed.entries.add(contactEntry)
}
// Submit the batch request to the server.
val responseFeed =
contactsService.batch(URL(BATCH_URL), requestFeed)
} catch (ex: java.lang.Exception) {
return false
}
return true
}
I could also remove contacts from a label and delete a label, and still I had to use getFeed(), ContactFeed, batch , etc...
But now with People API all I get is instances of Person, which is nothing similar to ContactEntry , and I can't find similar classes to replace those that are used here.
Is it still possible to do as I did before? The docs say that People API does support writing (here) :
Note: For read and write access to users' contacts, use the People API, which provides both contact and profile information using JSON instead of the older GData protocol.
but when going there, this is the only thing I see that's similar to what I had: https://developers.google.com/people/v1/other-contacts#copy-an-other-contact-to-mycontacts-group
It seems that in general it is possible to manage them, but not to copy from other-contacts to them: https://developers.google.com/people/api/rest/v1/contactGroups.members/modify
The only system contact groups that can have members added are contactGroups/myContacts and contactGroups/starred. Other system contact groups are deprecated and can only have contacts removed.
So, why can't I do this anymore? And is there a way to at least call copyOtherContactToMyContactsGroup (here) in a batch way instead of one after another ?
Closing this issue as we are unable to provide adequate customer support through this forum. If you feel there is a bug or a feature request associated with this ticket, please open a new issue. Otherwise, https://cloud.google.com/support is best able to provide timely answers to API-specific questions.