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
asked a year ago55 views
4 Answers
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
answered a year ago
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

answered a year ago
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.

answered a year ago
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!

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions