google-api - 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 字符串。创建事务、列出事务和列出事务都可以正常工作。我尝试了不同的字段组合以包含在请求正文中,但文档不清楚哪些是必需的......
解决方案
事实证明,您不能在 hold().create() 中使用“电子邮件”——您必须使用 accountId,或者 gmail 用户的“id”号码。
推荐阅读
- javascript - 如何将函数修复到允许下一个函数正确计算的位置?
- c# - Azure 函数使用了不正确的 DLL 版本
- angular - 如何使用谷歌云存储的 gsutil 将 POST curl 转换为 Angular http POST?
- javascript - 如何在节点服务器上发出同步 http 请求?
- character-encoding - 如何配置 Jetty 以正确解释文件名中的 UTF-8
- python - .py 文件和 .ipynb 文件有什么区别?
- javascript - 正则表达式(或不)用动态变量替换所有匹配项
- ios - 如何使用 Swift 将 JSON 数组数据加载到 UITableView 部分和行中?
- c++ - 为什么以下使用 boost 词法转换的程序在英特尔编译器上失败而不是 gcc(编译器错误)?
- reporting-services - 链接到 SSRS 报告以直接下载 PDF