#! /usr/bin/env python # vi:ts=4:et import pycurl from io import BytesIO c = pycurl.Curl() c.setopt(c.URL, 'https://httpbin.org/put') c.setopt(c.UPLOAD, 1) data = '{"json":true}' # READDATA requires an IO-like object; a string is not accepted buffer = BytesIO(data.encode('utf-8')) c.setopt(c.READDATA, buffer) c.perform() c.close()