Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,465,490
Community Members
 
Community Events
176
Community Groups

Jira REST API Update Summary of a ticket

Hello, struggling to edit a ticket summary, I can already post comments with below: 

 

So I've been able to use python to sumbit a JSON POST command using the below code:

 

    def Send_Answer(comment, URL):

        request2 = session.post(URL, cookies=cookies, json = {
           
    "body": comment,
        })
        #soup = BeautifulSoup(response2.content, 'lxml')
        print("Request status code is ", request2.status_code)
           
    def Get_New_Link(ticket_url = 'Error, link required.'):
        response2 = session.get(ticket_url, cookies=cookies, allow_redirects=False)
        soup = BeautifulSoup(response2.content, 'lxml')
        index_code = soup.find_all('div', class_ = 'sd-comment-issue-page-edit-root')
        parse_text = index_code
        parse_text = str(parse_text)
        parse_text = parse_text.split(':')
        parse_text = parse_text[1]
        parse_text = re.sub('[^0-9]','', parse_text)
        custom_link = ('https://mycompanyurl/rest/api/2/issue/'+parse_text+'/comment')
        return custom_link

 

Despite my best efforts I can't update the summary. I've tried many combos including changing the link to and the JSON:

 

    def Send_Answer(comment, URL):
     
        request2 = session.post(URL, cookies=cookies, json = {
           
    "summary": "Testchange"
        })
        #soup = BeautifulSoup(response2.content, 'lxml')
        print("Request status code is ", request2.status_code)
       

    def Get_New_Link(ticket_url = 'Error, link required.'):
        response2 = session.get(ticket_url, cookies=cookies, allow_redirects=False)
        soup = BeautifulSoup(response2.content, 'lxml')
        index_code = soup.find_all('div', class_ = 'sd-comment-issue-page-edit-root')
        parse_text = index_code
        parse_text = str(parse_text)
        parse_text = parse_text.split(':')
        parse_text = parse_text[1]
        parse_text = re.sub('[^0-9]','', parse_text)
        custom_link = ('https://mycompaniesurl/rest/api/2/issue/'+parse_text+'?fields=summary')
        return custom_link

3 answers

1 accepted

3 votes
Answer accepted

As per the Edit issue endpoint documentation, you don't update (change) an issue field with a POST request, but a PUT request.

Well seen,

I had not paid attention to the method!
I don't know how to develop in python so I didn't look at the code.
I'm more on PowerShell or Node js.
I think your answer can fix the problem

So simple ! That actually is likely the issue... I'm going to go down that rabbit hole using a PUT request instead of POST and see what I get. Thanks !

For anyone looking for a solution to this: 

 

Code: 

request2 = session.put(URL, cookies=cookies, json = {
           
            "fields": {"summary": "new summary"}
   
        })
Useful Link: 
Note:
Make sure to use the API Link without any additional text, just the /api/2/issue/issue_id

All of my attempts return a status code 405, so I know I'm close but lacking something I need. 

Hi,
Do you have a preference in the choice of programming language?

I don't really understand this python script

I prefer Python, this contains both. All this script is doing is sending a JSON Request to the REST API 

request2 = session.post(URLcookies=cookiesjson = {
           
    "summary""Testchange"
        })

So really I just need to figure out the right JSON code to send to the REST API to change a tickets summary

Suggest an answer

Log in or Sign up to answer