You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:Google People API的deleteContacts查询参数无法正常工作

Troubleshooting the 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 is https://www.googleapis.com/auth/contacts (which allows full contact management). If you're using a more restricted scope like contacts.readonly or contacts.other.readonly, the deleteContacts flag 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
    The deleteContacts parameter 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 passing deleteContacts=True instead of delete_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 deleteContacts parameter to true—it's easy to miss setting it properly in the UI.

  • Verify if contacts belong to other groups
    This is the most common gotcha! The deleteContacts=true flag 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 with deleteContacts=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 why deleteContacts didn'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ý

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:18:10