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 年前檢視次數 335 次
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 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南