Lambda and Textract: start_document_text_detection unknown parameter "OutputConfig"

Viewed 582

I am trying to extract text from a PDF using a Lambda Function and Textract.

My question is: How can I call "start_document_text_detection" so that Textract automatically sends its response to S3?

I get an error saying:

[ERROR] ParamValidationError: Parameter validation failed: Unknown parameter in input: "OutputConfig", must be one of: DocumentLocation, ClientRequestToken, JobTag, NotificationChannel

My code:

    textract = boto3.client('textract')
    textract.start_document_text_detection(
      DocumentLocation={
          'S3Object': {
              'Bucket': origin_bucket,
              'Name': key
          }
      },
      JobTag=key + '_Job',
      OutputConfig={
        "S3Bucket": destination_bucket,
        "S3Prefix": key
      })

Boto3 Documentation shows that I can pass a parameter called "OutputConfig": https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/textract.html#Textract.Client.start_document_text_detection

response = client.start_document_text_detection(
    DocumentLocation={
        'S3Object': {
            'Bucket': 'string',
            'Name': 'string',
            'Version': 'string'
        }
    },
    ClientRequestToken='string',
    JobTag='string',
    NotificationChannel={
        'SNSTopicArn': 'string',
        'RoleArn': 'string'
    },
    OutputConfig={
        'S3Bucket': 'string',
        'S3Prefix': 'string'
    }
)

AWS Textract's official documentation also says it is a valid parameter:

Another optional parameter available is OutputConfig, which lets you adjust where your output will be placed. By default, Amazon Textract will store the results internally, and can only be accessed by the Get API operations. With OutputConfig enabled, you can set the name of the bucket the output will be sent to, and its file prefix, where you can download your results as JSON. This allows for use of a user created bucket for storing results.

https://docs.aws.amazon.com/textract/latest/dg/api-async.html

1 Answers

You seem to be using an older version of boto3. Upgrading to the latest version (>1.16.36) should solve your problem.

Related