Share via

API translate: The request is not authorized because credentials are missing or invalid.

nickCroat 116 Reputation points
2024-10-13T08:08:36.61+00:00

Hi,

I created new Azure account, free one, I am using all corect data but all the time response is:
The remote server returned an error: (401) Unauthorized.
I tired in postman in regular code of web page... on Azure it is stated:
Status: Active
Location: West Europe
API Kind: TextTranslation
Pricing tier: Free

Any help please?

$headers = @{
    "Ocp-Apim-Subscription-Key" = "mykeysomething..."
    "Ocp-Apim-Subscription-Region" = "westeurope"
    "Content-Type" = "application/json"
}

$body = '[{"Text":"Ovo je tekst koji želim prevesti"}]'  Invoke-WebRequest -Uri "https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&from=hr&to=fr" `
  -Method POST -Headers $headers -Body $body

Azure Translator in Foundry Tools

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.