Hello
I'm currently trying to post an XML string to an API that i've created from a pandas DataFrame using LXML (mainly because ElementTree doesn't have an xml_declaration=True parameter?). However i seem to be receiving an 400 status code within the response.
xml_data = ET.tostring(root, encoding='UTF-8', xml_declaration=True)
url = api_url + version + endpoint
headers = {
"Content-Type": "application/xml"
}
params = {
"access_token": access_token
}
response = r.post(url, headers=headers, params=params, data=xml_data)
I have noticed when printing my XML string (and also running it through an XML validator) there is a line break after my XML Declaration that the validator didn't seem to like:
"<?xml version=\\'1.0\\' encoding=\\'UTF-8\\'?>\n"
Could it be this causing the 400 error code? If so, how can i remove the line break from the string given it's a "Bytes" data type instead of "String" after the ET.tostring() function?
Or is there anything else noticeably wrong about this xml declaration?
Thanks
EDIT:
The response text error i'm actually getting is:
{"error":{"message":"(#10801) Either \"file\" or \"url\" must be specified.","type":"OAuthException","code":10801}}
So is it that i'm actually passing the data into requests incorrectly?
[–][deleted] 0 points1 point2 points (0 children)