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
Hi, I would agree with Riku: it is confirmed by documentation at https://docs.aws.amazon.com/textract/latest/dg/API_S3Object.html