aws-samples / aws-samples/amazon-textract-code-samples
InvalidParameterException: Request has invalid parameters when using startDocumentAnalysis
- Ngôn ngữ chính
- Jupyter Notebook
- Star
- 449
- Fork
- 262
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
**Description**
I'm encountering an InvalidParameterException: Request has invalid parameters error when attempting to use the startDocumentAnalysis method with AWS Textract in a Node.js application. The error occurs despite ensuring that all parameters are correctly specified.
**Environment**
- Node.js Version: 18.20.3
- AWS SDK Version: ^2.1548.0
- AWS Region: ap-south-1
**Here's the code I'm using**
```
public async startAnalyiseDocument(key: string) {
try {
const response = await this.textreact
.startDocumentAnalysis({
DocumentLocation: {
S3Object: {
Bucket: env.AWS_BUCKET_NAME as string,
Name: key as string,
},
},
FeatureTypes: [
"TABLES", "FORMS", "SIGNATURES"
],
NotificationChannel:{
RoleArn:env.AWS_ROLE_ARN as string,
SNSTopicArn: env.AWS_SNS_TOPIC_ARN as string,
},
})
.promise();
console.log('ERROR:',response.$response.error)
return response;
} catch (error) {
console.log("AWS_TXT:", error);
throw new Error(error);
}
}
```
**Error Details**
```
InvalidParameterException: Request has invalid parameters
at Request.extractError (/Users/arunroot/Documents/mark93/node_modules/aws-sdk/lib/protocol/json.js:80:27)
at Request.callListeners (/Users/arunroot/Documents/mark93/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/Users/arunroot/Documents/mark93/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/Users/arunroot/Documents/mark93r/node_modules/aws-sdk/lib/request.js:686:14)
at Request.transition (/Users/arunroot/Documents/mark93/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/Users/arunroot/Documents/mark93/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /Users/arunroot/Documents/mark93r/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/Users/arunroot/Documents/mark93/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/Users/arunroot/Documents/mark93/node_modules/aws-sdk/lib/request.js:688:12)
at Request.callListeners (/Users/arunroot/Documents/mark93/node_modules/aws-sdk/lib/sequential_executor.js:116:18) {
code: 'InvalidParameterException',
'[__type]': 'See error.__type for details.',
'[Message]': 'See error.Message for details.',
time: 2024-07-04T18:31:17.960Z,
requestId: 'd05e66d4-2b18-446e-938e-de9b56864963',
statusCode: 400,
retryable: false,
retryDelay: 79.76554747215391
}
```
**Additional Information**
- The `RoleArn` and `SNSTopicArn` are correctly specified and the IAM role has the necessary permissions.
- Before implementing `NotificationChannel` it was working fine.
Hướng dẫn đóng góp
Hướng nghiên cứu
Điểm vào liên quan là lệnh gọi startDocumentAnalysis được hiển thị trong issue, đặc biệt là khối NotificationChannel được thêm vào. Trước tiên, hãy kiểm tra các tham số yêu cầu của AWS SDK cùng với các giá trị role và topic được cung cấp dựa trên các yêu cầu API đã được ghi rõ. Hoàn tất khi có thể tái tạo yêu cầu mà không gặp InvalidParameterException và ghi lại cấu hình được chấp nhận.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- aws, node.js
- Lĩnh vực
- backend, cloud
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 28/100