I am in need of batch processing documents. Here is my code:
const { DocumentProcessorServiceClient } = require("@google-cloud/documentai").v1;
const client = new DocumentProcessorServiceClient()
const name = `projects/${projectId}/locations/${location}/processors/${processorId}`;
const request = {
name,
inputDocuments: {
gcsDocuments: {
documents: [
{
gcsUri: 'gs://${bucketName}/1691859276860-958070983.pdf',
mimeType: 'application/pdf'
}
]
},
},
documentOutputConfig: {
gcsOutputConfig: {
gcsUri: `${bucketName}/${gcsOutputUri}/${gcsOutputUriPrefix}`,
},
},
};
// Batch process document using a long-running operation.
// You can wait for now, or get results later.
// Note: first request to the service takes longer than subsequent
// requests.
const [operation] = await client.batchProcessDocuments(request);
I matched the request type according to the doc correctly. texthttps://cloud.google.com/document-ai/docs/samples/documentai-batch-process-document
But I got this error message.
Error processing files: Error: 3 INVALID_ARGUMENT: Request contains an invalid argument.
I'm not sure what the problem is. I've tested the client.processDocument()
with this credential based on the doc and it worked correctly. What did I do wrong?
Also I tried to find the correct request type of batch process document but there is no correct explanation.