简体   繁体   English

Google Document AI - 参数无效

[英]Google Document AI - Invalid argument

I am very new in google Document AI, I tried to use this code but still have this response.我是 google Document AI 的新手,我尝试使用此代码但仍然有此响应。 Do you have any idea what I'm doing wrong?你知道我做错了什么吗? I have installed from nuget Google.Cloud.DocumentAI.V1我已经从 nuget 安装了 Google.Cloud.DocumentAI.V1

Status(StatusCode="InvalidArgument", Detail="Request contains an invalid argument.", DebugException="Grpc.Core.Internal.CoreErrorDetailException: {"created":"@1643889903.765000000","description":"Error received from peer ipv4:142.250.186.42:443","file":"......\src\core\lib\surface\call.cc","file_line":1067,"grpc_message":"Request contains an invalid argument.","grpc_status":3}") Status(StatusCode="InvalidArgument", Detail="Request contains an invalid argument.", DebugException="Grpc.Core.Internal.CoreErrorDetailException: {"created":"@1643889903.765000000","description":"从对等 ipv4 收到的错误:142.250.186.42:443","file":"......\src\core\lib\surface\call.cc","file_line":1067,"grpc_message":"请求包含无效参数。 “,”grpc_status“:3}”)

    public async void Start()
    {
        Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", @"path-to-json");

        try
        {
            //Generate a document
            string pdfFilePath = @"path-to-invoice-pdf";
            var bytes = File.ReadAllBytes(pdfFilePath);
            ByteString content = ByteString.CopyFrom(bytes);

            // Create client
            DocumentProcessorServiceClient documentProcessorServiceClient = await DocumentProcessorServiceClient.CreateAsync();
            // Initialize request argument(s)

            ProcessRequest request = new ProcessRequest
            {
                ProcessorName = ProcessorName.FromProjectLocationProcessor("ProjectID", "eu", "ProcessorID"),
                SkipHumanReview = false,
                RawDocument = new RawDocument
                {
                    MimeType = "application/pdf",
                    Content = content
                }
            };



            // Make the request
            ProcessResponse response = await documentProcessorServiceClient.ProcessDocumentAsync(request);

            Document docResponse = response.Document;

            Console.WriteLine(docResponse.Text);

        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }


    }

Quoted from this doc :引自这个文档

Note that if you wish to use DocumentProcessorServiceClient other than in the US, you must specify the endpoint when you construct the client.请注意,如果您希望在美国以外的地方使用DocumentProcessorServiceClient ,则必须在构建客户端时指定端点。 The endpoint is of the form {location}-documentai.googleapis.com, eg eu-documentai.googleapis.com.端点的形式为 {location}-documentai.googleapis.com,例如 eu-documentai.googleapis.com。 The simplest way to specify the endpoint is to use DocumentProcessorServiceClientBuilder :指定端点的最简单方法是使用DocumentProcessorServiceClientBuilder

DocumentProcessorServiceClient client = new DocumentProcessorServiceClientBuilder
{
    Endpoint = "eu-documentai.googleapis.com"
}.Build();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 处理来自 GCS 的文档时,文档 AI 处理文档失败,参数无效 - Document AI process document fails with invalid argument when processing docs from GCS 谷歌文档 AI 标签任务 - Google Document AI Labeling Task 带有 Salesforce 的 Google Document AI(发票 OCR) - Google Document AI(invoice OCR) with Salesforce 使用 Google Document AI(表单解析器 API)进行身份验证 - Authentication with Google Document AI (Form Parser API) Google Document AI api 认证错误 - Google Document AI api authentication error 使用 Google Document AI 的 OCR 多列文本 - OCR multi column text with Google Document AI 使用谷歌云文档 AI 处理器进行 PDF 分析和文档生成 - Using Google Cloud Document AI Processors for PDF analysis and document generation Google Document Ai 为同一文件提供不同的输出 - Google Document Ai giving different outputs for the same file 由于已解决的错误,Google Document AI 训练失败 - Google Document AI training fails due to an error that is already addressed 由于“智能文档质量处理器”现在不可用,如何在 google document AI 中获取文档质量分数? - How to get the document quality score in google document AI as the "Intelligent document quality processor" is not available now?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM