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: