【发布时间】:2023-01-17 01:22:44
【问题描述】:
我正在尝试使用 .NET 框架测试向 Document AI 发送请求。我没有看到关于使用客户端库的正式 Google 解释的任何特定于 .NET 的信息。 到目前为止,这是我想出的:
public void Test()
{
var documentProcessorServiceClient = new DocumentProcessorServiceClientBuilder
{
Endpoint = "us-documentai.googleapis.com"
}.Build();
ProcessRequest request = new ProcessRequest
{
SkipHumanReview = false,
RawDocument = new RawDocument
{
MimeType = "application/pdf",
Content = ByteString.CopyFrom(bytesArray); // bytesArray of some file
}
};
try
{
ProcessResponse response = documentProcessorServiceClient.ProcessDocument(request);
Document docResponse = response.Document;
Console.WriteLine(docResponse.Text);
}
catch (Exception ex)
{
throw;
}
}
我的问题是:
-
为什么我总是得到以下异常: “启动 gRPC 调用时出错。HttpRequestException:无法从 HttpRequestMessage 获取子通道。”
-
如何使用密钥而不是使用 OAuth2 进行身份验证?
谢谢。
成功发送带有身份验证的请求。
【问题讨论】: