This pretty need API - https://atlassian-python-api.readthedocs.io/jira.html
How do I get the response from an operation like:
jira.issue_update(jira_key,fields=fields)
jira.issue_create(fields)
It seems to just be "null" or NoneType .....
I would like to get like a 204 NoContent etc etc ...
Hello @Normann P_ Nielsen _Netic_
Reference - https://atlassian-python-api.readthedocs.io/index.html
Install package using pip
pip install atlassian-python-api
Please find the below code examples
from atlassian import Jira
jira = Jira(
url='',
username='',
password=''
)
# Get issue details
key = 'ATP-4'
issue = jira.issue(key)
print(issue) # prints issue details in dict format
print(issue['fields']['summary']) # print just the summary
#Update the summary of the issue
fields = {
'summary': 'Updated Summary from API'
}
jira.update_issue_field(key, fields, notify_users=True)
Thanks & Regards,
Pramodh
Hi @Pramodh M
But that was not the question - the question is - can You get the actual result of :
jira.update_issue_field(key, fields, notify_users=True)
and print it...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Normann P_ Nielsen _Netic_
Let me know if you would require help with any other field format?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The only thing I need help to is how to get the server response of jira.issue_update(jira_key,fields=fields) and jira.issue_create(fields)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Normann P_ Nielsen _Netic_
I tried the below scenario, let me know if this works?
issue_key = "ATP-4"
fields = {
"summary": "Updated summary using direct PUT"
}
# Full absolute URL required by requests
url = f"{jira.url}/rest/api/2/issue/{issue_key}"
response = jira._session.put(url, data=json.dumps({"fields": fields}),
headers={"Content-Type": "application/json"})
print("Status Code:", response.status_code)
print("Response Text:", response.text or "No content (likely 204)")
Thanks and Regards,
Pramodh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi @Pramodh M
That is fine I guees - but - You left out most parts of the API - https://atlassian-python-api.readthedocs.io/jira.html ... so is an answers, but not really an answer to my question, as You have to know the url
{jira.url}/rest/api/2/issue/{issue_key}
and the point with the API is abstracting from that.
But thanks for a possible solution
BR,
Normann
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Normann P_ Nielsen _Netic_
Well, while that is not possible. You could extend the class as below
from atlassian import Jira
import json
class JiraWithResponse(Jira):
def issue_create_with_response(self, fields):
response = self._session.post("rest/api/2/issue", data=json.dumps({"fields": fields}),
headers={"Content-Type": "application/json"})
return response.status_code, response.json()
def issue_update_with_response(self, issue_key, fields):
url = f"rest/api/2/issue/{issue_key}"
response = self._session.put(url, data=json.dumps({"fields": fields}),
headers={"Content-Type": "application/json"})
return response.status_code
Then, you can have the code as below
jira = JiraWithResponse(
url='https://your-domain.atlassian.net',
username='your-email@example.com',
password='your-api-token'
)
issueKey = ""
# Create issue and get response code
status_code, data = jira.issue_create_with_response(fields)
print(status_code, data)
# Update issue and get response code
status = jira.issue_update_with_response(issueKey, fields)
print(status)
Let me know if this works!
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.