by shigemk2

当面は技術的なことしか書かない

pycurl with json

stackoverflow.com

たぶんこういう感じの使い方。

#!/usr/bin/python
import os, sys, pycurl
model = """{
name: 'zxy',
targets: [ 'abc']
}"""
path = '/deployments/MyApp.ear'
c = pycurl.Curl()
c.setopt(pycurl.URL, 'https://abc.cde')
c.setopt(pycurl.HTTPHEADER, ['Accept:application/json'])
send = [("model", model),
        ('deployment', (pycurl.FORM_FILE, path)),]
c.setopt(pycurl.HTTPPOST, send)
#c.setopt(pycurl.VERBOSE, 1)
c.perform()
print c.getinfo(pycurl.RESPONSE_CODE)
c.close()