Entering the following code at the MAC terminal results in an error.
Microsoft Azure only configures the Translator in Marketplace and enters the key and the key in the Endpoint column into the Ocp-Apim-Subscription-Key.
Is there anything else to set up?
Will I be able to use it after a while after setting it up?
Once this problem has been cleared, I would like to use it in Python's program.
Thank you for your cooperation.
curl-X POST "https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&from=en&to=zh-Hans" \
-H"Ocp-Apim-Subscription-Key:88daf33****"\
-H"Content-Type: application/json; charset=UTF-8"\
-d"[{'Text':'Hello, what is your name?'}]"
{
"error": {
"code": 401000,
"message": "The request is not authorized because credentials are missing or invalid."
}
}
Resolved by specifying regions with the following arguments:
(I used it as an official reference, but I also stumbled.)
-H "Ocp-Apim-Subscription-Region:eastasia"
Modified Commands
curl-X POST "https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&from=en&to=zh-Hans" \
-H "Ocp-Apim-Subscription-Region:eastasia"\
- H "Ocp-Apim-Subscription-Key:********"\
-H"Content-Type: application/json; charset=UTF-8"\
-d"[{'Text':'Hello, what is your name?'}]"
Reference
https://stackoverflow.com/questions/61573396/translator-text-api-microsoft-azure-always-error-401000
© 2024 OneMinuteCode. All rights reserved.