Skip to content
Advertisement

Azure Form Recognizer error Atribute error when making the request

I’m trying to follow this document for the form recognizer API, specifically the example for Recognize receipts:

JavaScript

I’m trying the following code:

JavaScript

And getting this error:

JavaScript

The difference I see is that in the example the endpoint and key are called as attributes of a class:

JavaScript

But I do not see where does the “self.” comes from and how is that the value is not a string.

Advertisement

Answer

I agree that it is a bit unclear in the quickstart where that key is coming from. In the example, the API key is getting set as a class variable (where the self is coming from), but you do not need to do this to get your code working.

For successful authentication, the string API key “XXXXXXXXX” must be wrapped in the credential class AzureKeyCredential. I’ve updated your code below to do this, please let me know if it works for you:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement