Skip to content

Facing difficult in sending a request to document ai processor #25951

@nshganesh

Description

@nshganesh

https://cloud.google.com/document-ai/docs/process-documents-client-libraries following this documentation on making a request to individual document processing.

According to the below screenshot, we need to send a base64 encoded image.
Screenshot 2024-05-24 at 2 50 44 PM

But https://cloud.google.com/document-ai/docs/process-documents-client-libraries suggests without encoding approach.

content = File.binread file_path

Both approaches:

On making a request without base64 encoding, getting the below error:

**An error occurred when inspecting the object: #<ArgumentError: invalid byte sequence in UTF-8>
Result of Kernel#inspect: #<Google::Cloud::DocumentAI::V1::ProcessResponse:0x0000000128b78670 @descriptor=#<Google::Protobuf::Descriptor:0x0000000125b89ec8>>**

On making a request with base64 encoding, getting the below error:

bin_file = File.binread file_path
content = Base64.strict_encode64(bin_file)

**3:Invalid image content. debug_error_string:{UNKNOWN:Error received from peer ipv6:%5B2404:6800:4007:81e::200a%5D:443 {created_time:"2024-05-24T14:54:57.103571+05:30", grpc_status:3, grpc_message:"Invalid image content"}} (Google::Cloud::InvalidArgumentError)**

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions