Share via

Error 2019 FormRecognizer API REST trying to get analyze custom form results using cURL

2022-03-01T16:02:53.603+00:00

Hi, we have trained a model, we analyze a file from a container (using SAS URL) getting an "202 Accepted" response and an Operation-Location, but when we try to get the results we get 2019 error "Analyze JSON request was not in the expected format." We've tried uploading a binary pdf file using content-type application/pdf and it does work and we get the JSON result.

POST

curl -v "https://mariogallego1990.cognitiveservices.azure.com/formrecognizer/v2.1/custom/models/6492cea0-d505-4c73-bef1-8c167d2a5132/analyze" -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key: 4e41a8052c0144bababe914781d9e231" -d "{'source' : 'https://marioblob1990.blob.core.windows.net/hotelsa2/hotelsa1.pdf?sp=r&st=2022-03-01T15:40:12Z&se=2022-03-01T23:40:12Z&spr=https&sv=2020-08-04&sr=b&sig=xMq5nsub6BMGHoHtDhidjyK2Lhylj1E%2BVRJf2WxLkXU%3D'}"
* Trying 20.61.99.32:443...
* Connected to mariogallego1990.cognitiveservices.azure.com (20.61.99.32) port 443 (#0)
* schannel: disabled automatic use of client certificate
* schannel: ALPN, offering http/1.1
* schannel: ALPN, server accepted to use http/1.1

POST /formrecognizer/v2.1/custom/models/6492cea0-d505-4c73-bef1-8c167d2a5132/analyze HTTP/1.1
Host: mariogallego1990.cognitiveservices.azure.com
User-Agent: curl/7.79.1
Accept: /
Content-Type: application/json
Ocp-Apim-Subscription-Key: 4e41a8052c0144bababe914781d9e231
Content-Length: 215

>
* Mark bundle as not supporting multiuse
< HTTP/1.1 202 Accepted
< Content-Length: 0
< Operation-Location: https://mariogallego1990.cognitiveservices.azure.com/formrecognizer/v2.1/custom/models/6492cea0-d505-4c73-bef1-8c167d2a5132/analyzeresults/1fc3028a-f86e-4a70-aab2-3d4aa6c346ab
< x-envoy-upstream-service-time: 406
< apim-request-id: f6b82cf2-4cdf-49dd-b51a-a027a190cca2
< Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
< x-content-type-options: nosniff
< Date: Tue, 01 Mar 2022 15:43:31 GMT

GET

C:\Users\59004605> curl -X GET "https://mariogallego1990.cognitiveservices.azure.com/formrecognizer/v2.1/custom/models/6492cea0-d505-4c73-bef1-8c167d2a5132/analyzeresults/1fc3028a-f86e-4a70-aab2-3d4aa6c346ab" -H "Ocp-Apim-Subscription-Key: 4e41a8052c0144bababe914781d9e231"
{"status": "failed", "createdDateTime": "2022-03-01T15:43:31Z", "lastUpdatedDateTime": "2022-03-01T15:43:32Z", "analyzeResult": {"version": null, "readResults": null, "pageResults": null, "documentResults": null, "errors": [{"code": "2019", "message": "Analyze JSON request was not in the expected format."}]}}

Azure Document Intelligence in Foundry Tools

1 answer

Sort by: Most helpful
  1. test29998411 301 Reputation points
    2022-03-09T23:53:46.137+00:00

    I had the same issue as well. In my case, when I create the model, I set useLabelFile to true and then analyse it and the error is resolved.

    # create model
    curl -i -X POST "https://${endpoint}/formrecognizer/v2.1/custom/models" \
        -H "Content-Type: application/json" \
        -H "Ocp-Apim-Subscription-Key: ${subscription}" \
        --data-ascii "{'source': '""${sas_url}""', 'useLabelFile':true}}"
    

    I did not specify anything in the request body when analyzing.

    curl -v "https://${endpoint}/formrecognizer/v2.1/custom/models/${model_id}/analyze" \
        -H "Content-Type: application/json" \
        -H "Ocp-Apim-Subscription-Key: ${subscription}"
    

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.