Google 文档 AI - 参数无效

Google Document AI - Invalid argument

我是 google 文档 AI 的新手,我尝试使用此代码但仍然有此响应。你知道我做错了什么吗? 我已经从 nuget Google.Cloud.DocumentAI.V1

安装

Status(StatusCode="InvalidArgument", Detail="请求包含无效参数。", 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);
        }


    }

引自此doc

Note that if you wish to use DocumentProcessorServiceClient other than in the US, you must specify the endpoint when you construct the client. The endpoint is of the form {location}-documentai.googleapis.com, e.g. eu-documentai.googleapis.com. The simplest way to specify the endpoint is to use DocumentProcessorServiceClientBuilder:

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