Я получаю ответ XML от API, используя библиотеку запросов в Python.Но когда я анализирую ответ в python согласно принятому ответу здесь .Я использую следующий код для этого.
try:
# Prepare request
payload = "<DataRequest><groupcode>ABC</groupcode><employeeno>123456</employeeno></DataRequest>"
url = config['SF_Credentials']['end_point']
headers = {"Authorization": config['SF_Credentials']['authorization'], "Content-Type":"text/xml"}
response = requests.post(url, data = payload, headers= headers)
if response.status_code >300:
print('error in getting ecard', response.text)
xml_data = ET.fromstring(response.text)
print(dir(xml_data), xml_data.text)
print('done')
except Exception as e:
print('exception in getting ecard', e)
, но print(xml_data.text)
дает вывод None.Мой ответ API:
<?xml version="1.0" encoding="utf-8"?><DocumentElement><EcardInformation>https://integration.medibuddy.in/MediAssistAPI/DownloadEcard/4021172954/name/123</EcardInformation></DocumentElement>'
Я использую почтовый звонок, в отличие от вопроса, указанного выше.Имеет ли это какое-то значение в этом случае?или что-то еще мне не хватает?Кроме того, вывод response.text
равен
<?xml version="1.0" encoding="utf-8"?><DocumentElement><EcardInformation>https://integration.medibuddy.in/MediAssistAPI/DownloadEcard/4021172954/Name/1234</EcardInformation></DocumentElement>
Заранее спасибо.