Troubleshooting of Azure Cognitive Services API: Difference between revisions
Jump to navigation
Jump to search
Troubleshooting of Azure Cognitive Services API (edit)
Revision as of 16:19, 21 April 2022
, 21 April 2022→How to fix the error: invalid subscription key or wrong API endpoint
mNo edit summary |
|||
| Line 7: | Line 7: | ||
Solution: | Solution: | ||
* Verify the API endpoint | * Verify the API endpoint URL | ||
* Verify the subscription key and add to request header | * Verify the subscription key and add it to the request header | ||
Example command edited from the API document<ref>[https://docs.microsoft.com/zh-tw/azure/cognitive-services/Computer-vision/quickstarts-sdk/client-library?pivots=programming-language-rest-api&tabs=visual-studio 快速入門:光學字元辨識 (OCR) 用戶端程式庫或 REST API - Azure Cognitive Services | Microsoft Docs]</ref> | Example command edited from the API document<ref>[https://docs.microsoft.com/zh-tw/azure/cognitive-services/Computer-vision/quickstarts-sdk/client-library?pivots=programming-language-rest-api&tabs=visual-studio 快速入門:光學字元辨識 (OCR) 用戶端程式庫或 REST API - Azure Cognitive Services | Microsoft Docs]</ref> | ||
<pre> | <pre> | ||
curl -v -X POST "<API endpoint>" -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key: <subscription key>" --data-ascii "{\"url\":\"<image URL>\"}" | curl -v -X POST "<API endpoint>" -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key: <subscription key>" --data-ascii "{\"url\":\"<image URL>\"}" | ||
</pre> | |||
<pre> | |||
curl -v -X POST "https://westcentralus.api.cognitive.microsoft.com/vision/v3.2/read/analyze" -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key: <subscription key>" --data-ascii "{\"url\":\"https://upload.wikimedia.org/wikipedia/commons/thumb/a/af/Atomist_quote_from_Democritus.png/338px-Atomist_quote_from_Democritus.png\"}" | |||
</pre> | </pre> | ||