[Python-Dev] How to set/update value in a xml file using requests in python
Sum J
sjsumitj at gmail.com
Thu Feb 8 03:38:00 EST 2018
More information about the Python-Dev mailing list
Thu Feb 8 03:38:00 EST 2018
- Previous message (by thread): [Python-Dev] libxml2 installation/binding issue
- Next message (by thread): [Python-Dev] How to set/update value in a xml file using requests in python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
My xml file is located in local network: http://192.168.43.109/DevMgmt/NetAppsDyn.xml Below is a part content of above xml I want to update : <nadyn:NetAppsDyn> <nadyn:ProxyConfig> <dd:ResourceURI/> <dd:Port/> <dd:ProxySupport>off</dd:ProxySupport> </nadyn:ProxyConfig> </nadyn:NetAppsDyn> I want to set the value for 'ResourceUI' and 'Port' field in above xml. I have used below code : import requests data = { 'ResourceURI':'web-proxy.xxx.yy.com', 'Port':8080 } URL = 'http://192.168.75.165/DevMgmt/NetAppsDyn.xml' # content type head = {'Content-type': 'text/xml'} # sending get request gr= requests.get(url=URL) print gr # sending put request r = requests.put(url=URL, data=data,headers=head) print r.status_code # extracting response text output_xml = r.text print("The op xml is:%s" % output_xml) Issue : The fields are not getting updated in xml using put request. I am able to see the response for get (request) , but for put request it is throwing errror code : 301 , resource has been moved permanently. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20180208/2df09d61/attachment.html>
- Previous message (by thread): [Python-Dev] libxml2 installation/binding issue
- Next message (by thread): [Python-Dev] How to set/update value in a xml file using requests in python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list