项目xxxxxx之前未使用过云文档AI API或已禁用
调用 google document 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:{“创建”:“@1646997388.673000000”,“描述”: “从对等方 ipv4 收到错误:234.234324.324234:443”,“文件”:“......\src\core\lib\surface\call.cc”,“file_line”:1070,“grpc_message”: “xxxxxx项目之前未使用过云文档AI API或该API已被禁用。 通过访问 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 角色添加到服务帐户
最终修复 
While calling google document api, getting below error. apis are enabled, even after waiting for few hours still getting same error. any suggestion
RpcException: Status(StatusCode="PermissionDenied", Detail="Cloud Document AI API has not been used in project xxxxxxx before or it is disabled.
Enable it by visiting https://console.developers.google.com/apis/api/documentai.googleapis.com/overview?project=xxxxxxx then retry.
If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
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 has not been used in project xxxxxx before or it is disabled.
Enable it by visiting https://console.developers.google.com/apis/api/documentai.googleapis.com/overview?project=xxxx then retry.
If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.","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);
after fixing correct project id, as shown in developer console -> Prediction endpoint
Detail="Permission 'documentai.processors.processOnline' denied on resource
'//documentai.googleapis.com/projects/8xxxxxxxx7/locations/us/processors/axxxxxxxxxx1f' (or it may not exist)."
Adding Document AI Role to service account
final fix

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于@anand (OP) 已经解决了上述更新问题中提到的第一个问题,OP 收到了以下最近的错误。
此错误与用于验证 API 的服务帐户的权限有关。
您可以通过导航至IAM & 更新您的服务帐户权限。管理员> IAM

您可以在该列表上导航并从该页面编辑您的服务帐户的权限。您可以按照此文档了解如何为文档设置服务帐户身份验证人工智能。
由于您的错误消息显示您在
documentai.processors.processOnline
上遇到问题,因此您可以向您的服务帐户授予 Cloud DocumentAI API User 角色,因为它具有以下权限:还涵盖了错误消息中的一个:documentai.operations.getLegacy
、documentai.processors.processOnline
、documentai.processors.processBatch
。您还可以参考此Document AI IAM 角色文档 有关 Document AI 预定义角色的更多信息。
Since @anand (OP) has already fixed the first issue as mentioned on the above updated question, OP got the below recent error
This error is related on the permission of the service account being used to authenticate the API.
You may update your Serivce Account permission by navigating to IAM & Admin > IAM

You may navigate on the list and edit the permission of your service account from that page. You may follow this documentation on how to setup service account authentication for Document AI.
Since your error message shows that you are having issues on
documentai.processors.processOnline
, you may grant the Cloud DocumentAI API User role to your service account since it has below permissions which also covered the one on your error message:documentai.operations.getLegacy
,documentai.processors.processOnline
,documentai.processors.processBatch
.You may also refer to this Document AI IAM Roles Documentation for more information on the pre-defined roles for Document AI.