Search code examples
apexcloud-document-ai

Set processOptions for doc ai ocr api request


We are recommended to activate a flag on our OCR processor for better results because we face some problems (like "I" parsed as "1". To test the flag I want to use Postman, but adding the options to my requests results in an error. My Request:

{

 "skipHumanReview": true,
 "processOptions": {
    ...
  },

  "rawDocument": {
    "mimeType": "application/pdf",
    "content": "..."
  },

  "fieldMask": "text,pages.blocks,pages.paragraphs,pages.formFields"

}

Without the processOptions part, the requests works fine. ProcessOptions is not recognized. The Result is:

{ ... "message": "Invalid JSON payload received. Unknown name "processOptions": Cannot find field." ... }

The processor version used is pretrained-ocr-v1.2-2022-11-10 I don't know if I have a wrong version (the one used is the newest I see) or if my request is wrong (I didn't find an example with this flag). In our application we don't use the provided packages, but build the requests with custom code (APEX), so I will have the same problem using that.

Update: I found some examples and I am sure, that my request is correct. Then I guess it has to be the version, but pretrained-ocr-v1.2-2022-11-10 is the newset one I get offered enter image description here

Can somebody explain why?


Solution

  • Currently, ProcessOptions can only be specified when using the v1beta3 endpoint. https://documentai.googleapis.com/v1beta3

    This documentation shows how to add the field to the processRequest

    This Python sample shows how to add some options to ocr_config the official samples will be updated to include this field once the options are added to the v1 endpoint.

    https://github.com/GoogleCloudPlatform/document-ai-samples/tree/main/pdf-embedded-text

    Previous Answers about this: