question

Aaron-1796 avatar image
0 Votes"
Aaron-1796 asked Aaron-1796 commented

error: 401000 Authorization error - Azure Translator

For some reason I am getting this error from endpoint:

  {'error': {'code': 401000, 'message': 'The request is unauthorized because credentials are missing or invalid.'}}

I did nothing, any kind of change, the script done in python (3.6) was working correctly and then I started getting this error about authorization.

Tried some changes like, use endpoint for my region (westeurope), renew key, use second key, even used alternative method with "Authorization: Bearer key" instead of "Ocp-Apim-Subscription-Key" like documentation says but nothing works.

Here are the screenshots with the settings I hope someone can help me, thanks.

118001-image.png

117964-image.png



azure-translator
image.png (7.3 KiB)
image.png (15.7 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

GiftA-MSFT avatar image
0 Votes"
GiftA-MSFT answered

Hi, thanks for reaching out. Please try the following sample code (resource region is West Europe):

 import requests
 import json
    
 url = "https://api-eur.cognitive.microsofttranslator.com/translate?api-version=3.0&to=fr"
    
 payload = json.dumps([
   {
     "Text": "Hello, what is your name?"
   }
 ])
 headers = {
   'Ocp-Apim-Subscription-Key': 'ENTER KEY',
   'Content-Type': 'application/json',
   'Ocp-Apim-Subscription-Region': 'westeurope'
 }
    
 response = requests.request("POST", url, headers=headers, data=payload)
    
 print(response.text)


Output:

117988-image.png



image.png (121.8 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Aaron-1796 avatar image
0 Votes"
Aaron-1796 answered Aaron-1796 commented

Still getting the same error:


 {'error': {'code': 401000, 'message': 'The request is not authorized because credentials are missing or invalid.'}}


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Okay. If it was working before and then it stopped, then there may be an issue with your subscription. I suggest creating a Support Request for further investigation.


0 Votes 0 ·

I did mate, thanks for your help anyway

0 Votes 0 ·