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달 전344회 조회
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달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠