[英]Cloud Document AI API has not been used in project xxxxxx before or it is disabled
While calling google document api, getting below error.调用谷歌文档 api 时,出现以下错误。 apis are enabled, even after waiting for few hours still getting same error.
api 已启用,即使等待几个小时后仍然出现相同的错误。 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 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,请等待几分钟,让操作传播到我们的系统 and retry.","grpc_status":7}")
然后重试。","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修复正确的项目 ID 后,如开发人员控制台 -> 预测端点所示
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将文档 AI 角色添加到服务帐户
Since @anand (OP) has already fixed the first issue as mentioned on the above updated question, OP got the below recent error由于@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)."
This error is related on the permission of the service account being used to authenticate the API.此错误与用于验证 API 的服务帐户的权限有关。
You may update your Serivce Account permission by navigating to IAM & Admin > IAM您可以通过导航到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.
您可以按照此文档了解如何为 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.processors.processOnline
上遇到问题,您可以将Cloud DocumentAI API 用户角色授予您的服务帐户,因为它具有以下权限,也涵盖了您的错误消息中的权限:
documentai.operations.getLegacy
, documentai.processors.processOnline
, documentai.processors.processBatch
. 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.您还可以参阅此Document AI IAM 角色文档,了解有关 Document AI 预定义角色的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.