hinda32 on Mon, 19 Jun 2017 10:18:09

I am trying to call microsoft cognitive services translator with python using the following code: but i get errors, any idea why

from xml.etree import ElementTree
#from auth import AzureAuthClient
import requests

fromLangCode = "en"
toLangCode = "es"
textToTranslate = df #df is a data frame of text elements

# Call to Microsoft Translator Service

headers = {"Authorization ": 'zzzzzzzzzzzzzzzz'}
#translateUrl = "   text={}&to={}".format(textToTranslate, toLangCode)
translateUrl = "".format   (textToTranslate, toLangCode)
translationData = requests.get(translateUrl, headers = headers)
# parse xml return values
translation = ElementTree.fromstring(translationData.text.encode('utf-8')) 

I get an error File "", line unknown ParseError: not well-formed (invalid token)