0

The error is in the batchProcessDocuments:

{
  code: 3,
  details: 'Request contains an invalid argument.',
  metadata: Metadata {
    internalRepr: Map { 'grpc-server-stats-bin' => [Array] },
    options: {}
  },
  note: 'Exception occurred in retry method that was not classified as transient'
}

I've tried to copy the example as much as possible but without success. Is there a way of finding out more information regarding the input parameters that are required?

Here is my code sample:

const projectId = "95715XXXXX";
const location = "eu"; // Format is 'us' or 'eu'
const processorId = "a1e1f6a3XXXXXXXX";
const gcsInputUri = "gs://nmm-storage/test.pdf";
const gcsOutputUri = "gs://nmm-storage";
const gcsOutputUriPrefix = "out_";

// Imports the Google Cloud client library
const {
  DocumentProcessorServiceClient,
} = require("@google-cloud/documentai").v1beta3;
const { Storage } = require("@google-cloud/storage");

// Instantiates Document AI, Storage clients
const client = new DocumentProcessorServiceClient();
const storage = new Storage();

const { default: PQueue } = require("p-queue");

async function batchProcessDocument() {
  const name = `projects/${projectId}/locations/${location}/processors/${processorId}`;

  // Configure the batch process request.
  const request = {
    name,
    inputConfigs: [
      {
        gcsSource: gcsInputUri,
        mimeType: "application/pdf",
      },
    ],
    outputConfig: {
      gcsDestination: `${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); //.catch(err => console.log('err', err));
  // Wait for operation to complete.
  await operation.promise();

  console.log("Document processing complete.");
}

batchProcessDocument();
double-beep
  • 5,031
  • 17
  • 33
  • 41
  • As per your code, I believe you want to perform an assync offline file processing. Correct? Have you followed all the steps in the [documentation](https://cloud.google.com/document-ai/docs/ocr#batch-process) and used its code? Regarding your question about documentation, the parameters for the `request` can be found [here](https://cloud.google.com/document-ai/docs/reference/rest/v1beta2/Document) and the [documentation](https://googleapis.dev/python/documentai/latest/documentai_v1beta2/types.html) for `batchProcessDocument`. Did this information help you? – Alexandre Moraes Mar 08 '21 at 13:05
  • I've gone through the documentation and tried the input parameters in different formats without success – Brian Henderson Mar 08 '21 at 16:58
  • Have you copied the whole processor id ? Such as described [here](https://cloud.google.com/document-ai/docs/create-processor#use-endpoint). – Alexandre Moraes Mar 09 '21 at 08:46
  • 1
    Does this answer your question? [What argument is invalid for Google Document AI client library for Node js?](https://stackoverflow.com/questions/64888612/what-argument-is-invalid-for-google-document-ai-client-library-for-node-js) – Matt Fletcher Nov 03 '21 at 18:19
  • have you a news? – Cimo Feb 17 '23 at 12:41
  • FYI, there is an actively monitored tag for Document AI [cloud-document-ai] – Holt Skinner Mar 28 '23 at 20:52

1 Answers1

2

I think this is the solution: https://stackoverflow.com/a/66765483/15461811

(you have to set the apiEndpoint parameter)

Julius B
  • 81
  • 1
  • 3