I am trying to run the following curl
command in R.
curl -v -i POST "https://lanubiademorec.cognitiveservices.azure.com/formrecognizer/documentModels/prebuilt-invoice:analyze?api-version=2022-08-31" -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key: ******" --data-ascii "{'urlSource': 'https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/form-recognizer/invoice_sample.jpg'}"
I tried the following.
POST(URL,add_headers(.headers=c(`Ocp-Apim-Subscription-Key`= "****", `Content-Type`="application/json")), body=list('urlSource'= 'https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/form-recognizer/invoice_sample.jpg'))
And also this
POST(URL,add_headers(.headers=c(`Ocp-Apim-Subscription-Key`= "****")), body=list('urlSource'= 'https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/form-recognizer/invoice_sample.jpg'), content_type("application/json"))
Both return 400 error. The curl command works fine. Can anyone please help me identify the cause of the error and resolve it?