Translating Bash cURL commands to Python

I have the below working in Bash. How would this be written in Python using requests or pycurl?

curl -o .output_data.xml -v --cert ../cert/my_cert.pem:password123 -k '' -H 'Content-Type: application/json' -d '{"document":{"header":{"exportType":"XML"}}}'


Thanks to the comment from Tripleee regarding the below snippet now works:

I just needed to map the cURL option arguments correctly:

--cert maps to c.setopt(pycurl.SSLCERT, cert_file_path) and c.setopt(pycurl.SSLKEYPASSWD, "password123")

-k maps to c.setopt(pycurl.SSL_VERIFYPEER, False)

-H maps to c.setopt(pycurl.HTTPHEADER,["Content-Type: application/json"])

-d maps to c.setopt(pycurl.POSTFIELDS, json.dumps(params)) 

there is no mapping for -o so I capture the output using a buffer c.setopt(b.WRITEFUNCTION, b.write).

b.getvalue() will allow me to later parse the data from the captured XML string using Element Tree or similar.

import pycurl
import io
import json

cert_file_path = "../cert/my_cert.pem"
url = ""

b = io.BytesIO()
c = pycurl.Curl()
c.setopt(pycurl.URL, url)
c.setopt(pycurl.SSLCERT, cert_file_path)
c.setopt(pycurl.SSLKEYPASSWD, "password123")
c.setopt(pycurl.SSL_VERIFYPEER, False)
c.setopt(pycurl.HTTPHEADER,["Content-Type: application/json"])
c.setopt(pycurl.POSTFIELDS, json.dumps(params)) 
c.setopt(c.WRITEFUNCTION, b.write)
xml_string = b.getvalue().decode('UTF-8')