首页 > 解决方案 > Google Vault API HttpError 500“遇到内部错误。”

问题描述

尝试使用 Google Vault API 创建保全时出现以下错误:

请求https://vault.googleapis.com/v1/matters/ {matterId}/holds?alt=json时出现 HttpError 500, 返回“遇到内部错误。”

from google.oauth2 import service_account
import googleapiclient.discovery

SCOPES = ['https://www.googleapis.com/auth/ediscovery']
SERVICE_ACCOUNT_FILE = './serviceaccount.json'
credentials = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES)
delegated_credentials = credentials.with_subject('delegateuser@example.com')
client = googleapiclient.discovery.build('vault', 'v1', credentials=delegated_credentials)

data = { 'name': 'test', 'accounts': [{'email': 'testuser@example.com' }], 'corpus': 'MAIL', 'query': { 'mailQuery': {'terms': 'to:ceo@company.com'} }}

results = client.matters().holds().create(matterId='{matterId}', body=data).execute()

我已经用 {matterId} 替换了实际的 matterId 字符串。创建事务、列出事务和列出事务都可以正常工作。我尝试了不同的字段组合以包含在请求正文中,但文档不清楚哪些是必需的......

标签: google-apigoogle-api-client

解决方案


事实证明,您不能在 hold().create() 中使用“电子邮件”——您必须使用 accountId,或者 gmail 用户的“id”号码。


推荐阅读