0

I want data returned in JSON format instead of XML in the following code, where headers is the key to the API. requests.get(translateUrl,headers=headers) gives XML.

Call to Microsoft Translator Service

headers = {"Authorization ": finalToken}
translateUrl = "http://api.microsofttranslator.com/v2/Http.svc/Translate?text={}&to={}".format(textToTranslate, toLangCode)

translationData = requests.get(translateUrl, headers = headers)

# parse xml return values
translation = ElementTree.fromstring(translationData.text.encode('utf-8'))

# display translation
print (translation.text)
Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108

1 Answers1

0

There is an existing feature request for this.

For now you will have to convert it on the client side. Here is where you might additional info.

cthrash
  • 2,938
  • 2
  • 11
  • 10