By using AWS re:Post, you agree to the Terms of Use

Questions tagged with Amazon Textract

Sort by most recent

Browse through the questions and answers listed below or filter and sort to narrow down your results.

Error while calling API DetectDocumentTextAsync - One or more errors occurred. (Unable to get IAM security credentials from EC2 Instance Metadata Service

Hi I am sharing below error, dont know why this error showing.2-3 days before this code was working and now i am getting this error, i have not changed any setting. Please help to understand this error Code showing error var result = new DetectDocumentTextResponse(); var s3Object = new S3Object { Bucket = bucketName, Name = key }; var request = new DetectDocumentTextRequest(); request.Document = new Document { S3Object = s3Object }; // line returning error return await this.textract.DetectDocumentTextAsync(request); System.AggregateException HResult=0x80131500 Message=One or more errors occurred. (Unable to get IAM security credentials from EC2 Instance Metadata Service.) Source=System.Private.CoreLib StackTrace: at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at Dotnet_Core.ArgHandlers.DetectTextS3Handler.Handle(String bucketName, String s3File) in D:\amazon-textract-code-samples-master\amazon-textract-code-samples-master\src-csharp\ArgHandlers\DetectTextS3Handler.cs:line 14 at Dotnet_Core.Program.Main(String[] args) in D:\amazon-textract-code-samples-master\amazon-textract-code-samples-master\src-csharp\Program.cs:line 55 This exception was originally thrown at this call stack: [External Code] Dotnet_Core.Services.TextractTextDetectionService.DetectTextS3(string, string) in TextractTextDetectionService.cs Inner Exception 1: AmazonServiceException: Unable to get IAM security credentials from EC2 Instance Metadata Service.
2
answers
0
votes
27
views
asked a month ago

Texttract - Why does subsequent GetDocumentAnalysisAsync(getResultsRequest) Blocks have no relationships populated

Hi and thank you for any help you can provide... I am using Texttract with the .Net SDK. I am able to successfully submit and get the results of a TABLE analysis job and now I am trying to loop through the results. I can make my first call to GetDocumentAnalysisAsync then I loop through the blocks that are type CELL so I can get Row and Column ID and then I will look through all of the relationships cells to get the text. This all works fine up to the point I need to get the next blocks with a call to GetDocumentAnalysisAsync passing the nexttoken ID. I then get the next set of CELL block and begin looping again. This time, none of my CELL blocks have any relationships populated to get the text from. I just get what looks like a lot of empty cells. I have verified the page is readable through the console demo page so there should be text there. Here is my code (in c#) I am using to iterate through the blocks and retrieve the next set of blocks. ``` if (getResultsResponse.JobStatus == JobStatus.SUCCEEDED) { do { getResultsResponse.Blocks.ForEach(x => { if (x.BlockType.Equals("CELL")) { Console.WriteLine("Page: " + x.Page.ToString()); Console.WriteLine("Rowindex: " + x.RowIndex.ToString()); Console.WriteLine("Colindex: " + x.ColumnIndex.ToString()); x.Relationships.ForEach(y => { y.Ids.ForEach(z => { var cellText = (from text in getResultsResponse.Blocks where text.Id == z.ToString() select text.Text).FirstOrDefault(); if (!string.IsNullOrEmpty(cellText)) { Console.Write($"{cellText} "); } }); }); } }); if (string.IsNullOrEmpty(getResultsResponse.NextToken)) { break; } getResultsRequest.NextToken = getResultsResponse.NextToken; getResultsResponse = await _textractClient.GetDocumentAnalysisAsync(getResultsRequest); } while (getResultsResponse.Blocks.Count > 0); } ```
3
answers
0
votes
36
views
asked a month ago