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
質問済み 10ヶ月前343ビュー
1回答
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
エキスパート
回答済み 10ヶ月前
profile picture
エキスパート
レビュー済み 10ヶ月前
profile pictureAWS
エキスパート
レビュー済み 10ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ