There's an API that I am experimenting with that outputs XML.
Could anyone tell me if I have something wrong my code to parse the API response or is it a problem with the API itself?
I can use a put command with this:
import requests
import xml
from xml.etree import ElementTree
response = requests.post("https://openadrtester.herokuapp.com/api/v1/cpp/senorio/three")
string_xml = response.content
tree = xml.etree.ElementTree.fromstring(string_xml)
xml.etree.ElementTree.dump(tree)
But it will error out on:
Traceback (most recent call last):
File "C:\Users\bbartling\OneDrive - Slipstream\Desktop\myAPI\tut\test.py", line 7, in <module>
tree = xml.etree.ElementTree.fromstring(string_xml)
File "C:\Users\bbartling\AppData\Local\Programs\Python\Python37\lib\xml\etree\ElementTree.py", line 1315, in XML
parser.feed(text)
File "<string>", line None
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 0
XML is also viewable through the browser on a get request:
string_xmlcontain if youprint()it in your code?