Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to update fields by POST REST in Python

nir.eyal@siemens.com October 14, 2022

Hello,

 

I am trying to update a field ( for example fields status), using the POST method from Python.

I followed the documentation but when i check the result the status of issue doesn't changed.

 

Here is the code I try to run:

 

in this example I want to change status to "Request Info" with:

import requests
from requests.auth import HTTPBasicAuth
import json

auth = ('myuser', 'mypassword!')

# set the url
url = "myorganizationurl/rest/api/2/issue/SF-6831/transitions"

# simulating that the transition id will be status : TO DO
data = {"transition": {"id": 331}}

#make the authenticated request to the JIRA API
r = requests.post(url, auth=auth, json=data)

print ("HERE's the JSON RESPONSE\n\n ", r.status_code, r.headers)

would be great if you can guide my through on how to update not only this field but also ( comments, fix version, Reporter, Description ,Priority ,Team...)

 

Thanks.

 

1 answer

0 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 14, 2022

Welcome to the Atlassian Community!

There's a lot in here, bur to start with the basics:

  • What python library are you using to talk to Jira?
  • What is the response message from Jira when you do this?
  • Where is the rest of the data you need to post when performing a transition?
nir.eyal@siemens.com October 14, 2022
  • I only using the following libraries :
import requests
from requests.auth import HTTPBasicAuth
import json
  •  the response i get is:

HERE's the JSON RESPONSE

400 {'X-AREQUESTID': '747x3930128x1', 'X-ANODEID': 'valor-node1', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'X-XSS-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'Content-Security-Policy': 'sandbox', 'Strict-Transport-Security': 'max-age=31536000, max-age=31536000; includeSubDomains; preload', 'Set-Cookie': 'JSESSIONID='my organozation url~9E7BDB018BA8A606191943CB4B0548D6; Path=/; Secure; HttpOnly; Secure, atlassian.xsrf.token={token number}dfe3eee6863338a274543_lin; Path=/; Secure; SameSite=None; Secure', 'X-Seraph-LoginReason': 'OK', 'X-ASESSIONID': '19m10vv', 'X-AUSERNAME': 'muuser', 'Cache-Control': 'no-cache, no-store, no-transform', 'Content-Encoding': 'gzip', 'Vary': 'User-Agent', 'Content-Type': 'application/json;charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Date': 'Fri, 14 Oct 2022 11:27:27 GMT'}

 

 

  • that is what I need to know, if I am missing anything in my code to change the status of the issue.
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 14, 2022

Umm, that's not a response, that's a response header.

If you've hit a Jira REST endpoint, it will have given you a success or failure response, with some detail on what it has done or what went wrong.  If you've tried to hit an invalid one, the response would say that it's not valid.

We need to know what the content of the response is.

Suggest an answer

Log in or Sign up to answer