How do i send xml file to http request in python and what are the packages that need to be installed in ubuntu

Question:

How do i send xml file to http request(to web url) in python 2.7 or 3.3 or 3.4 and what are the packages that need to be installed in ubuntu..

Asked By: user2667081

||

Answers:

import requests url = “192.168.6.x:8089/test/request?”; files =””” “”” r = requests.post(url, str(files)) print (r.text) print(r.elapsed)

Answered By: user2667081

this worked for me:

with open(f"/tmp/{filename}") as xml:
    files = {'file': xml}
    response = requests.post(url=complete_url, verify=CA_CERT, cert=(TLS_CERT, TLS_KEY), files=files, timeout=600)
    response.raise_for_status()
Answered By: Akhilesh Joshi
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.