求助:Google People API的deleteContacts查询参数无法正常工作
deleteContacts Parameter Not Working in Google People API Hey there, let's break down why your deleteContacts parameter isn't behaving as expected when deleting a contact group. I've run into similar quirks with the People API before, so here are the most likely fixes to try:
Double-check your permission scopes
Make sure your API credentials have the right permissions to delete contacts. The minimum required scope ishttps://www.googleapis.com/auth/contacts(which allows full contact management). If you're using a more restricted scope likecontacts.readonlyorcontacts.other.readonly, thedeleteContactsflag will silently fail to delete contacts—even though the group itself gets removed. Verify your OAuth scopes in your project's Google Cloud Console and in your code.Confirm the contact group type
ThedeleteContactsparameter only works with user-created custom groups. System-generated groups (like "Starred contacts", "Recent contacts", or default domain groups) don't allow deleting contacts via this method. If your test group is a default one, that's why the contacts stick around—you'll need to create a custom group for testing this functionality.Check parameter naming (critical for Python)
The official Google Python client uses snake_case for parameters, not camelCase. If you're passingdeleteContacts=Trueinstead ofdelete_contacts=True, the API won't recognize the parameter at all. Your Python code should look something like this:from googleapiclient.discovery import build service = build('people', 'v1', credentials=creds) service.contactGroups().delete( resourceName='contactGroups/{GROUP_ID}', delete_contacts=True ).execute()Even in the API Explorer, double-check that you've toggled the
deleteContactsparameter totrue—it's easy to miss setting it properly in the UI.Verify if contacts belong to other groups
This is the most common gotcha! ThedeleteContacts=trueflag only deletes contacts that exist exclusively in the group you're deleting. If any of your test contacts are part of another group (even a hidden system group), they'll just be removed from the deleted group instead of being deleted entirely. To test this, create a new custom group, add contacts that aren't in any other groups, then try deleting the group withdeleteContacts=true—those contacts should be removed from your account.Inspect the API response for hidden warnings
Even if the request returns a 200 OK status, check the response body for warning messages. Sometimes the API will include hints about whydeleteContactsdidn't execute (e.g., "Contacts belong to other groups" or "Insufficient permissions"). Print the response in your Python code or check the "Response" tab in the API Explorer to see these details.
内容的提问来源于stack exchange,提问作者Matěj Marčišovský

