I am trying use curl in python with url parameter but it is returning "None", same api with same parameter in php it is working fine. Here is my python code :
from StringIO import StringIO
import pycurl, json
apiurl = 'http://servername.com:7705'
data = json.dumps({"node": "test", "type": "get_by_field"})
c = pycurl.Curl()
c.setopt(pycurl.URL, apiurl)
c.setopt(pycurl.HTTPHEADER, ['Accept: application/json'])
c.setopt(pycurl.POST, 1)
c.setopt(pycurl.POSTFIELDS, data)
response = c.perform()
c.close()
print response
Try this
import StringIO
import pycurl, json
fout = StringIO.StringIO()
apiurl = 'http://servername.com:7705'
data = json.dumps({"node": "test", "type": "get_by_field"})
c = pycurl.Curl()
c.setopt(pycurl.WRITEFUNCTION, fout.write)
c.setopt(pycurl.URL, apiurl)
c.setopt(pycurl.HTTPHEADER, ['Accept: application/json'])
c.setopt(pycurl.POST, 1)
c.setopt(pycurl.POSTFIELDS, data)
c.perform()
c.getinfo(pycurl.RESPONSE_CODE)
fout.getvalue()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.