简体   繁体   中英

how to write queries using python and REST to retrieve data from JIRA

I am trying to create a script using python and REST to get data from JIRA,currently am able to get data for each JIRA ticket using the code shown below,I want to be able to write queries to retrieve large data which I do currently from the UI as shown below,how can I update my current script to achieve this from the script?

Query: "project = ITTICKETS AND "Build Info" ~ CI_-STD.INT-2"

Python code:-

import requests
import json
import logging
import datetime
import base64
serverURL = 'https://jira.company.com/jira'
user = 'username'
password = 'password'
jql = '/rest/api/2/issue/JIRATICKET-152133'
response = requests.get(serverURL + jql,verify=False,auth=(user, password))
print response
#print response.data
print response.json()

Try setting jql like this:

import urllib
query = 'project = ITTICKETS AND "Build Info" ~ CI_-STD.INT-2'
jql = '/rest/api/2/search?jql=%s' % urllib.quote(query)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM