Reputation: 1
I'm trying to test sending a request to Document AI using .NET framework. I didn't see any info specific to .NET on the formal Google explanations for using client libraries. So far this is what I came up with:
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;
}
}
My questions are:
Why I always get the following exception: "Error starting gRPC call. HttpRequestException: Unable to get subchannel from HttpRequestMessage."
How do I authenticate using a key instead of using OAuth2?
Thanks.
Successfully send the request with authentication.
Upvotes: 0
Views: 922
Reputation: 2234
This page in the documentation has been updated to include a Quickstart Sample for C#/.NET.
https://cloud.google.com/document-ai/docs/libraries#client-libraries-install-csharp
Here is the full API Documentation for C#
https://cloud.google.com/dotnet/docs/reference/Google.Cloud.DocumentAI.V1/latest
Upvotes: 0