I have this curl command to execute by means of pycurl library:
curl https://lipn.univ-paris13.fr/framester/en/wfd_json/sentence -d "data=Remember the milk:t" -X PUT
and this is my pycurl conversion:
url = "https://lipn.univ-paris13.fr/framester/en/wfd_json/sentence"
buffer = StringIO()
curl = pycurl.Curl()
curl.setopt(pycurl.CAINFO, certifi.where())
curl.setopt(curl.URL, url)
pycurl.HTTPHEADER, ['Content-Type: application/json' ,'Accept: application/json']
curl.setopt(pycurl.CUSTOMREQUEST, "PUT")
curl.setopt(pycurl.POST, 1)
curl.setopt(pycurl.VERBOSE, 1)
data = urllib.urlencode({"data":"Remember the milk:t"})
curl.setopt(pycurl.POSTFIELDS, data)
curl.setopt(curl.WRITEFUNCTION, buffer.write)
curl.perform()
curl.close()
body = buffer.getvalue()
print(buffer.getvalue())
The problem is that the curl command returns a json, while when I execute through pycurl the elaboration doesn't stop. Can someone help me to correct my code? Why the python code doesn't stop? Thank you