amazon-web-services.net-coreamazon-textract

AWS Textract InvalidParameterException


I have a .Net core client application using amazon Textract with S3,SNS and SQS as per the AWS Document , Detecting and Analyzing Text in Multipage Documents(https://docs.aws.amazon.com/textract/latest/dg/async.html)

Created an AWS Role with AmazonTextractServiceRole Policy and added the Following Trust relation ship as per the documentation (https://docs.aws.amazon.com/textract/latest/dg/api-async-roles.html) { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "textract.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }

Subscribed SQS to the topic and Given Permission to the Amazon SNS Topic to Send Messages to the Amazon SQS Queue as per the aws documentation .

All Resources including S3 Bucket, SNS ,SQS are in the same us-west2 region

The following method shows a generic error "InvalidParameterException" Request has invalid parameters

But If the NotificationChannel section is commented the code is working fine and returning the correct job id.

Error message is not giving a clear picture about the parameter. Highly appreciated any help .

public async Task<string> ScanDocument()
{
            string roleArn = "aws:iam::xxxxxxxxxxxx:instance-profile/MyTextractRole";
            string topicArn = "aws:sns:us-west-2:xxxxxxxxxxxx:AmazonTextract-My-Topic";
            string bucketName = "mybucket";
            string filename = "mytestdoc.pdf";

            var request = new StartDocumentAnalysisRequest();
            var notificationChannel = new NotificationChannel();
            notificationChannel.RoleArn = roleArn;
            notificationChannel.SNSTopicArn = topicArn;

            var s3Object = new S3Object
            {
                Bucket = bucketName,
                Name = filename
            };
            request.DocumentLocation = new DocumentLocation
            {
                S3Object = s3Object
            };
            request.FeatureTypes = new List<string>() { "TABLES", "FORMS" };
            request.NotificationChannel = channel; /* Commenting this line work the code*/
            var response = await this._textractService.StartDocumentAnalysisAsync(request);
            return response.JobId;

        }

Solution

  • After a long days analyzing the issue. I was able to resolve it .. as per the documentation topic only required SendMessage Action to the SQS . But after changing it to All SQS Action its Started Working . But Still AWS Error message is really misleading and confusing