Community moderators have prevented the ability to post new answers.
I figured it out after. Seems I had to encode the body in JSON since I had the content-type as JSON. See below for the working code:
import httplib, json host = 'serebra.jira.com' baseUrl = '/rest/api/latest/' encodeUserData = 'Basic ' + ('username' + ':' + 'password').encode('base64').rstrip() conn = httplib.HTTPSConnection(host) headers = { 'Accept': 'application/json', 'Content-Type': 'application/json;charset=UTF-8', 'Authorization': encodeUserData, } body = json.dumps({ 'fields': { 'environment': 'test', } }) conn.request('PUT', baseUrl + 'issue/CP-2290', headers=headers, body=body) response = conn.getresponse() print response.status, response.reason print response.read()
It does. I've tried modifying many different fields as well. I've also tried using the "updates" options. But it's always a 400 Bad Request. Also, I provided a more readable example of the code (seems the editor doesn't work in Safari so I couldn't format anything). So yeah, the GET works fine... it's just I can't update the issue with a PUT.
import httplib, urllib, json host = 'example.jira.com' baseUrl = '/rest/api/latest/' encodeUserData = 'Basic ' + ('username' + ':' + 'password').encode('base64').rstrip() data = urllib.urlencode({ 'fields': { 'summary': 'test', }, }) request = httplib.HTTPSConnection(host) request.putrequest('PUT', baseUrl + 'issue/CP-2290', data) request.putheader('Accept', 'application/json') request.putheader('Content-type', 'application/json;charset=UTF-8') request.putheader('Authorization', encodeUserData) request.endheaders() response = request.getresponse() print response.status, response.reason print response.read()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not really using Python. However, does the description field get return when you use GET method for
rest/api/2/issue/CP-2290/editmeta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.