Need JS code for Azure Forms Recognizer rest api

Kesavamurthi D 106 Reputation points
2022-01-25T02:22:35.217+00:00

hi

i am using ocr labelling tool for scanning the invoices .i am able to get the output in json and csv.

but i have it to achieve it via JS code.

my url is "https://xxxxxxxx.cognitiveservices.azure.com/formrecognizer/v2.1/prebuilt/invoice/analyze?includeTextDetails=true"

as a result i need to store the result in a json file.
Using python i am able to do it but i need to have java script code or postman also will help.

VIA postman :
headers Content-Type application/pdf
Ocp-Apim-Subscription-Key : my form recognizer key
the url :https://xxxxxxxx.cognitiveservices.azure.com/formrecognizer/v2.1/prebuilt/invoice/analyze?includeTextDetails=true"
i am stuck how to pass the body wiht file path..
pls guide.

ex json output of my JS code would be (it is same as labelling tool output):
{"status": "succeeded",
"createdDateTime": "2022-01-24T23:19:53Z",
"lastUpdatedDateTime": "2022-01-24T23:19:56Z",
"analyzeResult": {
"version": "2.1.1",
"readResults": [
"pageResults": [
"documentResults": [
}
}

Azure AI Document Intelligence
Azure AI Document Intelligence
An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
1,531 questions
0 comments No comments
{count} vote

Accepted answer
  1. romungi-MSFT 43,691 Reputation points Microsoft Employee
    2022-01-25T09:19:30.117+00:00

    @Kesavamurthi D You should be able to achieve this using the samples from Azure form recognizer JS SDK repo. The endpoint, keys and model id are set as environment variables in this sample where the JS SDK is used.

    If you want to use postman for a local file then you need to use the following headers:

    Content-Type:image/jpeg  
    Ocp-Apim-Subscription-Key:<your_key>  
    

    For the body you need to set the type as binary and choose the file that you want to analyze and use the endpoint with the modelid that you want to analyze with.

    168271-image.png

    Copy the result operation location and use GET call with the header Ocp-Apim-Subscription-Key:<key> of your resource to get the JSON results:

    168194-image.png

    If an answer is helpful, please click on 130616-image.png or upvote 130671-image.png which might help other community members reading this thread.


0 additional answers

Sort by: Most helpful