Getting InvalidParameterException while calling texteract analyze_document

0

Please find below the code, I've replaced confidential contents with **.

import re
# boto3 client
textract = boto3.client(
    'textract', 
    region_name='**', 
    aws_access_key_id='**', 
    aws_secret_access_key='**'
)



response = textract.analyze_document(
            Document={'S3Object': {'Bucket': '**/todo', 'Name': '1.pdf'}},
    
            FeatureTypes=["FORMS",],
            HumanLoopConfig={
                'FlowDefinitionArn': 'arn:aws:sagemaker:us-east-1:**:flow-definition/analyse-text',
                'HumanLoopName': 'analyse-text1',
                'DataAttributes': {
                    'ContentClassifiers': [
                        'FreeOfPersonallyIdentifiableInformation','FreeOfAdultContent'
                    ]
                },
            },
          )

Here is Full error

InvalidParameterException Traceback (most recent call last) Cell In[3], line 1 ----> 1 response = textract.analyze_document( 2 Document={'S3Object': {'Bucket': '/todo', 'Name': '1.pdf'}}, 3
4 FeatureTypes=["FORMS",], 5 HumanLoopConfig={ 6 'FlowDefinitionArn': 'arn:aws:sagemaker:us-east-1:
:flow-definition/analyse-text', 7 'HumanLoopName': 'analyse-text1', 8 'DataAttributes': { 9 'ContentClassifiers': [ 10 'FreeOfPersonallyIdentifiableInformation','FreeOfAdultContent' 11 ] 12 }, 13 }, 14 )

File ~/Desktop/2023/env/lib/python3.11/site-packages/botocore/client.py:534, in ClientCreator._create_api_method.<locals>._api_call(self, *args, **kwargs) 530 raise TypeError( 531 f"{py_operation_name}() only accepts keyword arguments." 532 ) 533 # The "self" in this scope is referring to the BaseClient. --> 534 return self._make_api_call(operation_name, kwargs)

File ~/Desktop/2023/env/lib/python3.11/site-packages/botocore/client.py:976, in BaseClient._make_api_call(self, operation_name, api_params) 974 error_code = parsed_response.get("Error", {}).get("Code") 975 error_class = self.exceptions.from_code(error_code) --> 976 raise error_class(parsed_response, operation_name) 977 else: 978 return parsed_response

InvalidParameterException: An error occurred (InvalidParameterException) when calling the AnalyzeDocument operation: Request has invalid parameters

KK
asked 10 months ago321 views
1 Answer
2

Is it correct to include the folder name in "Bucket" in the following section?

Document={'S3Object': {'Bucket': '**/todo', 'Name': '1.pdf'}},

I thought the folder name should be included in "Name".

Document={'S3Object': {'Bucket': '**', 'Name': 'todo/1.pdf'}},
profile picture
EXPERT
answered 10 months ago
profile picture
EXPERT
reviewed 10 months ago
profile pictureAWS
EXPERT
reviewed 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions