Search code examples
pythonputpycurl

Pycurl PUT request to JIRA REST API waiting on 100 continue


I am trying to change the assignee in JIRA using pycurl. My code is waiting on ****HTTP/1.1 100 Continue****. What am I doing wrong? Thanks for your help. I have attached a snippet of my code below. Also I do not want to use the JIRA Python Library.

def assign(self, key, name):

    data = json.dumps({"fields":{"assignee":{"name":name}}}) 
    c= pycurl.Curl()
    c.setopt(pycurl.VERBOSE, 1)
    c.setopt(pycurl.URL, "http://xxx/rest/api/2/issue/"+ key )
    c.setopt(pycurl.HTTPHEADER, ['Content-Type: application/json', 'Accept: application/json'])
    c.setopt(pycurl.USERPWD, "****") 
    c.setopt(pycurl.PUT, 1) 
    c.setopt(pycurl.POSTFIELDS,data)
    c.perform()

Solution

  • Got the code working.

       def assign(self, key, name):
        self._startCurl()         
        self.c.setopt(pycurl.URL, "http://xxx/rest/api/2/issue/"+ key )
        self.c.setopt(pycurl.HTTPHEADER, ['Content-Type: application/json', 'Accept: application/json'])
        self.c.setopt(pycurl.USERPWD, "fred:fred") 
        self.c.setopt(pycurl.CUSTOMREQUEST, "PUT")
        data = json.dumps({"fields":{"assignee":{"name":name}}})
        self.c.setopt(pycurl.POSTFIELDS,data)        
        self.c.perform()
        self.c.close()