Troubleshooting of Azure Cognitive Services API: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
|||
| (4 intermediate revisions by the same user not shown) | |||
| 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> | ||
| Line 15: | Line 15: | ||
</pre> | </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> | |||
== How to fix the error: Failed to download image from input URL == | |||
Error message | |||
: <pre>{"error":{"code":"FailedToDownloadImage","message":"Failed to download image from input URL."}}</pre> | |||
Solution: | |||
* Check the form data submitted | |||
* Check the image URL | |||
== How to fix the error: Unsupported media type == | == How to fix the error: Unsupported media type == | ||
| Line 23: | Line 35: | ||
Solution: Add this item to request header | Solution: Add this item to request header | ||
: <pre>Content-Type: application/json</pre> | : <pre>Content-Type: application/json</pre> | ||
== Related pages == | |||
* [https://westus2.dev.cognitive.microsoft.com/docs/services/form-recognizer-api/operations/AnalyzeReceipt Cognitive Services APIs Reference] | |||
* [[Troubleshooting of HTTP errors]] | |||
== References == | == References == | ||
| Line 32: | Line 49: | ||
[[Category:Machine Learning]] | [[Category:Machine Learning]] | ||
[[Category:Data Science]] | [[Category:Data Science]] | ||
[[Category:Tool]] | |||
Latest revision as of 16:23, 21 April 2022
How to fix the error: invalid subscription key or wrong API endpoint[edit]
Error message
{"error":{"code":"401","message":"Access denied due to invalid subscription key or wrong API endpoint. Make sure to provide a valid key for an active subscription and use a correct regional API endpoint for your resource."}}
Solution:
- Verify the API endpoint URL
- Verify the subscription key and add it to the request header
Example command edited from the API document[1]
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 "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\"}"
How to fix the error: Failed to download image from input URL[edit]
Error message
{"error":{"code":"FailedToDownloadImage","message":"Failed to download image from input URL."}}
Solution:
- Check the form data submitted
- Check the image URL
How to fix the error: Unsupported media type[edit]
Error message
{"error":{"code":"BadArgument","message":"Unsupported media type."}}
Solution: Add this item to request header
Content-Type: application/json
Related pages[edit]
References[edit]
Troubleshooting of ...
- PHP, cUrl, Python, selenium, HTTP status code errors
- Database: SQL syntax debug, MySQL errors, MySQLTuner errors or PostgreSQL errors
- HTML/Javascript: Troubleshooting of javascript, XPath
- Software: Mediawiki, Docker, FTP problems, online conference software
- Test connectivity for the web service, Web Ping, Network problem, Web user behavior, Web scrape troubleshooting
Template