I am trying to edit a JIRA Issue using REST API . I get a 405 error when I run the following code.
I already read https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-edit-issues . But I don't understand why I am getting a 405.
I also checked https://**.atlassian.net/rest/api/latest/issue/TI-81/editmeta/ , which gives the list of fields I can edit.
newValues = dumps(
{
"update": {
"summary": [
{
"set": "blah "
}
]
}
})
newValues = dumps({
"fields":
{
"summary":"CLONE - Testing label stuff",
"assignee":{"name":"admin"}
}
})
headers = {"Authorization": " Basic " + b64encode(username + ":" + password), "Content-Type": "application/json"}
try:
request = requests.put("https://****.atlassian.net/rest/api/latest/issue/"+IssueID+"/editmeta", data=newValues, headers=headers)
print request
except urllib2.HTTPError, error:
print error.read()
Can someone help me with the issue or provide a working python code to edit issue by key/ID??
Community moderators have prevented the ability to post new answers.
Hello Jag,
Thank you for your question.
Please, run the following:
import requests, json, base64 username = 'YOUR_USERNAME' password = 'YOUR_PASSWORD' pageData = { "fields": { "summary":"NEW SUMMARY", "assignee":{"name":"USERNAME"}, "priority":{"id":"INTEGER"}, } } headers = { "Authorization": " Basic " + base64.b64encode(username + ":" + password), "Content-Type": "application/json" } print json.dumps(pageData) r = requests.put( 'https://DOMAIN.atlassian.net/rest/api/2/issue/ISSUE-KEY', data=json.dumps(pageData), headers=(headers) ) print r
If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.
Thank you for your understanding.
—
Kind regards,
Rafael P. Sperafico
Atlassian Support
Hi Jag,
The error 405 "Method not allowed" happens because urllib2 does POST instead of PUT. I also had this one.
The next code works for me:
opener = urllib2.build_opener(urllib2.HTTPHandler)
queryURL = serverURL + '/rest/api/latest/issue/' + taskID
newValue = {
"fields": {
"customfield_10500": new_value
}
}
req = urllib2.Request(queryURL)
req.add_data(json.dumps(newValue))
req.add_header("Content-type", "application/json")
req.add_header("Accept", "application/json")
req.get_method = lambda: 'PUT' # this line is the key!
fp = opener.open(req)
fp.close()
Best regards,
Eugene
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
fields might got added to screens more than once.
To identify duplicate entries use this query
select f.name, i.fieldidentifier, count(*) from fieldscreen f, fieldscreenlayoutitem i, fieldscreentab t where f.id = t.fieldscreen and i.fieldscreentab = t.id group by f.name, i.fieldidentifier having count(*) > 1;
Based on the results, remove those fields from respective screens.
Thank You
Madhu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.