Textract analyze.Expense throwing an error, "not a function"

0

Hello People,

Really will appreciate any help right now. Attempting to use the recently announced Textract invoices and receipts API.
Using the AWS SDK in Lambda running on Node 12. Textract executed fine, when I was using AnalyzeDocument, with the announcement I converted my script to use analyzeExpense.

executing the code below:
textract.analyzeExpense(invoiceParams, function(err, data) {
if (err) console.log(err, err.stack);
else console.log(data);
});

Getting the error:

"errorType": "TypeError",
"errorMessage": "textract.analyzeExpense is not a function",
"code": "TypeError",
"message": "textract.analyzeExpense is not a function"

Not sure what the challenge is, could it be that this function doesn't exist in the SDK yet?

m12s
질문됨 3년 전352회 조회
4개 답변
0

Most likely your local AWS SDK is old/not updated. Another possibility - since this function has been relatively recently added, if you are relying on AWS SDK Lambda image (that is, you don't ship your own AWS SDK as shared layer) then you could see the same problem.
Try adding your own AWS SDK (make sure the Expense function is in your SDK) as shared layer to your Lambda, redeploy and try again.

Regards,
Albert

AlbertK
답변함 3년 전
0

Hi,

Thanks for using our service! As we launch AnalyzeExpense recently, you probably need to get the latest SDK before calling AnalyzeExpense API. You can download the SDK from https://github.com/aws and make sure you are available to see AnalyzeExpense API locally. If the issue is still there after installing the latest SDK, please don't hesitate to let us know.

Thanks,
Shayne

답변함 3년 전
0

Did anyone manage to fix this issue? We're getting the same error in production (works fine locally) with the correct SDK version and settings. I'm not sure if it's because we've deployed it on a Lambda or if there's some other issue.

답변함 3년 전
0

I ended up fixing this error by using the v3 SDK instead of v2.965.0.
Really quite strange since Textract is supposed to be supported in v2.965.0 - I even took a peek at the code myself to confirm. If anyone else is having similar issues but still relies on some v2 functionality like we do (because v3 S3 is broken for us, go figure) - you can just install @aws-sdk/client-textract and use that separately.

Hope this helps someone in the future!

답변함 3년 전

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

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

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

관련 콘텐츠