Hi There,
I am trying to fetch all the issue keys of a specific project using JIRA python api and below is the code. For example, Can i please know how to fetch the issue keys with a specific label called "server".
url = "https://abcd.com/rest/api/2/search?maxResults=4"
auth = HTTPBasicAuth("cred, "password)
headers={
"Accept": "application/json",
"Content-Type": "application/json"
}
query = {
'jql': 'project = APACHE'
}
projectIssues = []
response=requests.get(url,headers=headers,params=query,auth=auth)
data=response.json()
issues=data["issues"]
for issue in issues:
projectIssues.append(issue["key"])
Thank you
Hello @peter
Welcome to the community.
Modify your jql query to be
'project = APACHE AND labels in ("server")'
That should get all issues from the APACHE project where "server" is one of the values in the Labels field. If you want to get issues where "server" is the only value in the Labels field then use this
'project = APACHE AND labels = "server" '
Thank you for the reply. I have tried the above mentioned solutions but however, issues are not getting filtered based on the labels, they are being filtered based on "maxresult=4"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What documentation are you referencing for this api? Can you provide a link?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What i mean to say is that when i added the labels in the code, it is not generating the issue keys based on labels instead it is provides first four issue keys based on maxResults=4
I am using the below documentation:
url = "https://abcd.com/rest/api/2/search?maxResults=4"
auth = HTTPBasicAuth("cred, "password)
headers={
"Accept": "application/json",
"Content-Type": "application/json"
}
query = {
'jql': 'project = APACHE AND labels = "server'
}
projectIssues = []
response=requests.get(url,headers=headers,params=query,auth=auth)
data=response.json()
issues=data["issues"]
for issue in issues:
projectIssues.append(issue["key"])
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I see I partially misunderstood your initial problem statement. I thought you were trying to use the Python Jira API. You are actually using the JIRA REST API in python code.
The correct link for the JIRA REST API documentation for the issue search function is:
Can you provide the full response you are getting? I don't recall exactly where, but I believe somewhere in there will be the full URL that actually got submitted. I suspect that the JQL query is not getting properly appended.
I would also suggest removing the ?maxResults=4 in your first line to see if that makes a difference. Are you intentionally trying to limit the results to just the first 4 items returned?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.