![](/img/trans.png)
[英]Firestore API has not been used in project 416788152002 before or it is disabled
[英]Cloud Document AI API has not been used in project xxxxxx before or it is disabled
调用谷歌文档 api 时,出现以下错误。 api 已启用,即使等待几个小时后仍然出现相同的错误。 任何建议
RpcException: Status(StatusCode="PermissionDenied", Detail="Cloud Document AI API之前没有在项目xxxxxxx中使用过或者被禁用了。访问https://console.developers.google.com/apis/api/启用它documentai.googleapis.com/overview?project=xxxxxxx然后重试。如果您最近启用了这个 API,请等待几分钟让操作传播到我们的系统并重试。", DebugException="Grpc.Core.Internal.CoreErrorDetailException: { "created":"@1646997388.673000000","description": "Error received from peer ipv4:234.234324.324234:443","file":"......\src\core\lib\surface\call.cc ","file_line":1070,"grpc_message": "Cloud Document AI API 之前没有在项目 xxxxxx 中使用过或者被禁用了。访问https://console.developers.google.com/apis/api/启用它documentai.googleapis.com/overview?project=xxxx然后重试。如果您最近启用了这个 API,请等待几分钟,让操作传播到我们的系统然后重试。","grpc_status":7}")
ByteString content = ByteString.CopyFrom(bytes);
DocumentProcessorServiceClient documentProcessorServiceClient = new DocumentProcessorServiceClientBuilder
{ CredentialsPath = "D:\\poised-aleph-3xx-6a3xxxx4343a03.json" }
.Build();
ProcessRequest request = new ProcessRequest
{
ProcessorName = ProcessorName.FromProjectLocationProcessor("invoiceprocessor", "us", "343431"),
SkipHumanReview = true,
RawDocument = new RawDocument
{
MimeType = "application/pdf",
Content = content
}
};
request.RawDocument.MimeType = "application/pdf";
request.RawDocument.Content = content;
// Make the request
ProcessResponse response = await
documentProcessorServiceClient.ProcessDocumentAsync(request);
修复正确的项目 ID 后,如开发人员控制台 -> 预测端点所示
Detail="Permission 'documentai.processors.processOnline' denied on resource
'//documentai.googleapis.com/projects/8xxxxxxxx7/locations/us/processors/axxxxxxxxxx1f' (or it may not exist)."
将文档 AI 角色添加到服务帐户
由于@anand(OP)已经解决了上述更新问题中提到的第一个问题,OP 得到了以下最近的错误
RpcException: Status(StatusCode="PermissionDenied", Detail="Permission 'documentai.processors.processOnline' denied on resource
'//documentai.googleapis.com/projects/xxxx/locations/us/processors/xxxxxx' (or it may not exist)."
此错误与用于验证 API 的服务帐户的权限有关。
您可以通过导航到IAM & Admin > IAM来更新您的服务帐户权限
您可以在列表中导航并从该页面编辑您的服务帐户的权限。 您可以按照此文档了解如何为 Document AI 设置服务帐户身份验证。
由于您的错误消息显示您在documentai.processors.processOnline
上遇到问题,您可以将Cloud DocumentAI API 用户角色授予您的服务帐户,因为它具有以下权限,也涵盖了您的错误消息中的权限:
documentai.operations.getLegacy
、 documentai.processors.processOnline
、 documentai.processors.processBatch
。
您还可以参阅此Document AI IAM 角色文档,了解有关 Document AI 预定义角色的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.