I have python write the file to disk for trouble shooting
Caused by: com.thoughtworks.xstream.io.StreamException: : only whitespace content allowed before start tag and not - (position: START_DOCUMENT seen -... @1:1)
Code:
timeout = 3
headers = {'content-type': 'text/xml'}
configFile = {'file': open(os.environ['NEWJOBXML'], 'rb').read()}
newjobxml = requests.post("http://" + os.environ['USER'] + ":" + os.environ['API_TOKEN'] + "@" + os.environ['JR_URL'] + "/createItem?name=" + newjob, files=configFile, headers=headers, timeout=int(timeout))
I get this for the header too:
{'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate',
'Authorization': 'Basic ********************************************************',
'Connection': 'keep-alive',
'Content-Length': '11629',
'User-Agent': 'python-requests/2.5.1 CPython/2.7.5 Darwin/13.3.0',
'content-type': 'text/xml'}
When I post the same xml via curl, no errors
curl -H "Content-type: text/xml" -X POST http://USER:API_TOKEN@JR_URL/createItem?name=newjob --data-binary @/tmp/.config.xml
I am trying to migrate my code from bash to python.
 
No comments:
Post a Comment