Google DocumentAI Java example fails with io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Request contains an invalid argument

So, turns out after reading this: What argument is invalid for Google Document AI client library for Node js?

that if the location is not “us” but “eu”, you have to specify an other endpoint.

Oh man, why did they not mention that in the tutorial or the source code? It just says:

    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String location = "your-project-location"; // Format is "us" or "eu".
    String processorId = "your-processor-id";
    String filePath = "path/to/input/file.pdf";

The really should have mentioned that it is not enough to switch to “eu”.

So the simple solution is, do not use

        try (DocumentProcessorServiceClient client = DocumentProcessorServiceClient.create()) {


        try (DocumentProcessorServiceClient client = DocumentProcessorServiceClient.create(
                DocumentProcessorServiceSettings.newBuilder().setEndpoint("").build())) {

Read more here: Source link