@Barbaros Özdemir The image here is passed with application/octet-stream header but the actual data passed in body is not binary data but instead a local file reference. This call will not pass the binary data. You need to pass the streaming data or actual binary data by reading the file, For example: With python you can read the file and call the API.
image_data = open(image_path, "rb").read()
headers = {'Ocp-Apim-Subscription-Key': subscription_key,
'Content-Type': 'application/octet-stream'}
params = {'visualFeatures': 'Categories,Description,Color'}
response = requests.post(
analyze_url, headers=headers, params=params, data=image_data)
response.raise_for_status()
# The 'analysis' object contains various fields that describe the image. The most
# relevant caption for the image is obtained from the 'description' property.
analysis = response.json()
print(analysis)
Full sample available here.
Since you already have the file as URI you can use the same in body of the request instead of downloading the file to local.
Example:
curl -H "Ocp-Apim-Subscription-Key: <subscriptionKey>" -H "Content-Type: application/json" "<your_endpoint>/vision/v3.2/analyze -d "{\"url\":\"https://www.acm.org/binaries/content/assets/publications/word_style/interim-template-style/interim-layout.pdf\"}"
UPDATE:
Below call to pass the local file should also work, the error in this case seems to be with the parameter as mentioned in further comments below:
curl --location --request POST "https://<your-resource>.cognitiveservices.azure.com/vision/v3.2/read/analyze?readingOrder=basic" --header "Content-Type: application/octet-stream" --header "Ocp-Apim-Subscription-Key: <your_key>" --data-binary "@/C:\\Users\\test\\Documents\\interim-layout.pdf"
If an answer is helpful, please click on or upvote
which might help other community members reading this thread.