CURL POST with Python

441 views Asked by At

I am trying to POST a multipart/base64 xml file to portal using the following in python. How can i run it in Python?

curl -X POST -H 'Accept: application/xml' -H 'Content-Type: multipart/related; boundary=<boundary_value_that_you_have>; type=text/xml; start=<cXML_Invoice_content_id>' --data-binary @<filename>.xml https://<customer_name>.host.com/cxml/invoices
1

There are 1 answers

0
Nabil On

You can use this website

I got this code. Could you try it ?

import requests

headers = {
    'Accept': 'application/xml',
    'Content-Type': 'multipart/related; boundary=<boundary_value_that_you_have>; type=text/xml; start=<cXML_Invoice_content_id>',
}

data = open('filename.xml', 'rb').read()

response = requests.post('https://<customer_name>.host.com/cxml/invoices', headers=headers, data=data)