@arpit.malviya Based on the error message are you using the correct keys of Azure translator resource? How are you passing the keys in the header?
Please try this script in python by replacing your key values from the translator resource.
import requests, uuid, json
# Add your subscription key and endpoint
subscription_key = "replace_your_key"
endpoint = "https://api.cognitive.microsofttranslator.com"
# Add your location, also known as region. The default is global.
# This is required if using a Cognitive Services resource.
location = "global"
path = '/translate'
constructed_url = endpoint + path
params = {
'api-version': '3.0',
'from': 'en',
'to': ['de', 'it']
}
constructed_url = endpoint + path
headers = {
'Ocp-Apim-Subscription-Key': subscription_key,
'Ocp-Apim-Subscription-Region': location,
'Content-type': 'application/json',
'X-ClientTraceId': str(uuid.uuid4())
}
# You can pass more than one object in body.
body = [{
'text': 'Hello World!'
}]
request = requests.post(constructed_url, params=params, headers=headers, json=body)
response = request.json()
print(json.dumps(response, sort_keys=True, ensure_ascii=False, indent=4, separators=(',', ': ')))
This script should print the following response:
If an answer is helpful, please click on or upvote
which might help other community members reading this thread.