Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python jira获取json_Python_Json_Python 2.7_Jira - Fatal编程技术网

Python jira获取json

Python jira获取json,python,json,python-2.7,jira,Python,Json,Python 2.7,Jira,我正试图从jiraapi获取json。为此,我使用python。 它有助于获取项目和问题信息。但我不知道如果我需要像这样从url获取json该怎么办: /jira/rest/structure/1.0/structure.json 以下是我的服务器端代码: from jira.client import JIRA jira_options = {'server': 'https://bits.example.com/jira'} try: jira = JIRA(options=ji

我正试图从jiraapi获取json。为此,我使用python。 它有助于获取项目和问题信息。但我不知道如果我需要像这样从url获取json该怎么办:

/jira/rest/structure/1.0/structure.json

以下是我的服务器端代码:

from jira.client import JIRA

jira_options = {'server': 'https://bits.example.com/jira'}

try:
    jira = JIRA(options=jira_options,
                basic_auth=('user', 'pass'))
    project =  jira.project('CTT')
    print project
    print(project.lead.displayName)
except Exception, e:
    print e.args[0]
    print "Failed to connect to JIRA"

因为您正在请求Python API中不可用的资源

您将希望使用请求库

import requests

response = requests.get('https://bits.example.com/jira/rest/structure/1.0/structure.json',
    auth=('user', 'pass'))

json = response.json()

TL;DR:您可以通过
raw
属性访问底层JSON表示。 例如:

jira=jira.jira(,basic_auth=(,) 问题=jira.问题(‘项目-1234’) 打印(原始版本) 详细回答:

JIRA问题和其他资源是Resource类的子类(参见上面的文件)。
一个常见属性是
raw
,据我所知,它存储从JIRA REST API调用获得的原始JSON数据。

请详细说明-1的原因?
jira = jira.JIRA(<jira server address>, basic_auth=(<username>, <password>))
issue = jira.issue('PROJ-1234')
print(issue.raw)