Convert curl example to pycurl Convert curl example to pycurl curl curl

Convert curl example to pycurl


You can use something like this. It's a basic implementation but it should work.

import pycurl, jsonpostmark_url = 'https://api.postmarkapp.com/email'data = json.dumps({"From": "user@example.com", "To": "receiver@example.com", "Subject": "Pycurl", "TextBody": "Some text"})c = pycurl.Curl()c.setopt(pycurl.URL, github_url)c.setopt(pycurl.HTTPHEADER, ['X-Postmark-Server-Token: API_TOKEN_HERE','Accept: application/json'])c.setopt(pycurl.POST, 1)c.setopt(pycurl.POSTFIELDS, data)c.perform()