Hi @counterpoint2022 , can you please check your PowerShell version? You need to install PowerShell version 7.*+ to run this POST request. More detailed instructions are here: https://learn.microsoft.com/en-us/azure/applied-ai-services/form-recognizer/quickstarts/try-v3-rest-api#prerequisites.
Issues with Get started: Form Recognizer REST API 2022-06-30-preview
Has anyone try the new preview Rest API? The cURL example described in the document.
I am getting "curl: (6) Could not resolve host: POST". Anyone else run into the same issue? Thanks
curl -v -i POST "https://westus.api.cognitive.microsoft.com/formrecognizer/documentModels/prebuilt-invoice:analyze?api-version=2022-06-30-preview" -H "Content-Type:application/json" -H "Ocp-Apim-Subscription-Key:xxxxxxxxxx" --data-ascii "{'urlSource': 'https://github.com/Azure-Samples/cognitive-services-REST-api-samples/raw/master/curl/form-recognizer/rest-api/invoice.pdf'}"
Azure AI Document Intelligence
2 answers
Sort by: Most helpful
-
Lu Zhang (AI) 106 Reputation points Microsoft Employee
2022-07-20T09:05:06.423+00:00 -
Anonymous
2022-07-26T11:31:46.753+00:00 Hi @counterpoint2022 , it looks like you forgot to specify the request method with
-X POST. SincePOSTis provided without an argument switch, curl assumesPOSTis a host name and the request fails with a DNS error since POST is not a valid Form Recognizer endpoint.Since curl supports multiple URLs in a single command the next argument (the valid Form Recognizer endpoint) should succeed (as it does for me on macOS with curl 7.79.1).
That said, the
-Xargument is optional when you provide a request body (e.g. with--data-ascii). Curl will automatically default the request method to POST when the body is provided.On a side note, your JSON body is technically using invalid JSON syntax, although Form Recognizer will currently accept it. A well-formed JSON string should use double quotes, not single quotes, for object properties.
The well-formed curl request should look like this:
curl -i 'https://westus.api.cognitive.microsoft.com/formrecognizer/documentModels/prebuilt-invoice:analyze?api-version=2022-06-30-preview' \ -H 'content-type: application/json' \ -H "ocp-apim-subscription-key: $MY_FR_KEY" \ --data '{"urlSource": "https://github.com/Azure-Samples/cognitive-services-REST-api-samples/raw/master/curl/form-recognizer/rest-api/invoice.pdf"}'