{"id":4639,"date":"2024-01-19T14:50:10","date_gmt":"2024-01-19T14:50:10","guid":{"rendered":"https:\/\/ibex.tech\/python\/?p=4639"},"modified":"2025-05-01T16:28:35","modified_gmt":"2025-05-01T15:28:35","slug":"http-post-with-xml","status":"publish","type":"post","link":"https:\/\/ibex.tech\/python\/tcp-ip\/http\/http-post-with-xml","title":{"rendered":"HTTP POST with XML"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>import requests\n\n    xml = \"\"\"&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?>\n    &lt;PTZAux>\n        &lt;id>1&lt;\/id>\n    &lt;\/PTZAux>\"\"\"\n\n    request_url = f\"http:\/\/some_domain.com\/some_file\"\n    headers = {'Content-Type': 'application\/xml'}\n    response = requests.post(request_url, data=xml, headers=headers, timeout=10)    #Timeout in secs\n    if response.status_code == 200:\n        print(\"Success: \\n\" + response.text)\n    else:\n        print(\"Error: \" + response.status_code)\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[369],"tags":[],"class_list":["post-4639","post","type-post","status-publish","format-standard","hentry","category-http"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/posts\/4639","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/comments?post=4639"}],"version-history":[{"count":5,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/posts\/4639\/revisions"}],"predecessor-version":[{"id":4923,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/posts\/4639\/revisions\/4923"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/media?parent=4639"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/categories?post=4639"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/tags?post=4639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}