I fetch some data from an api with below code
headers = {
'Authorization': "Basic XXXXXXXXX",
'Accept': 'application/xml',
}
resp = requests.get('https://api_request', headers=headers)
I receive a correct response from the API (code 200) but content is in bytes format so not easy to read. Printing the resp.content gives:
print(resp.content)
b'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><legalEntity xmlns="http://XXXX.io"><status>AGT_VALIDATED</status><id><code>140012</c.........
Is there a way to convert this in a easy to manipulate format so that I can extract the specific info I need?
resp.texttoxml.etree.ElementTree. See also How to read xml file using pythonresponse.json().