How to carry xml data when python implements put operation with requests library

question: python uses the requests library to implement put get for http. There is no problem with get now. You need to carry the data of xml when using PUT. Now the debugging is not successful and the coding error is prompted. If you have no experience, please guide us. The contents of the import requestsfrom requests.auth import HTTPDigestAuthfd = open ("defog.xml") dataxml = fd.read () auth= HTTPDigestAuth (" admin", "1111") r = requests.put (url = cameraurl,data = dataxml, auth=auth) print r.status_codedefog.xml file are as follows: < Defog > < enbaled > false < / enbaled > < defogStrength > 0 < / defogStrength > < / Defog > the error report is as follows: File "C:Python27libsite-packagesrequestsmodels.py", line 828, In content self._content = b"".join (self.iter_content (CONTENT_CHUNK_SIZE)) or baked "File "C:Python27libsite-packagesrequestsmodels.py", line 753, in generate raise ChunkedEncodingError (e) requests.exceptions.ChunkedEncodingError: ("Connection broken: error (10054,")", error (10054,"))

Mar.04,2022

have you changed the request header? try this headers = {'content-type':' application/xml'}

.
Menu