如何在jira python 1.0.7中获取附件链接和附件id?

如何在jira python 1.0.7中获取附件链接和附件id?,jira,jira-rest-api,python-jira,Jira,Jira Rest Api,Python Jira,我使用的是JIRA python 1.0.7。给定一个特定的问题,我正在尝试获取附件id和附件uri。jirapython文档说我可以通过以下属性访问附件 issue.fields.attachment issue.fields.attachment.id 但无论如何,我得到了这些错误 In [23]: issue.fields.attachment -------------------------------------------------------------------------

我使用的是JIRA python 1.0.7。给定一个特定的问题,我正在尝试获取附件id和附件uri。jirapython文档说我可以通过以下属性访问附件 issue.fields.attachment issue.fields.attachment.id 但无论如何,我得到了这些错误

In [23]: issue.fields.attachment
--------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/usr/lib/python3.4/site-packages/jira/jirashell.py in <module>()
----> 1 issue.fields.attachment
AttributeError: type object 'PropertyHolder' has no attribute 'attachment'

今天的1.0.7版本也有同样的问题:没有找到属性“附件”,但当我使用它时,实际上找到了它

您是否像我一样,使用
issues=jira.search\u issues()
首先检索问题?由于某种原因,它返回的对象缺少“附件”属性

但是,您可以通过调用
issue=jira.issue(issues[i].key)
来检索特定问题的新对象。此对象将具有“附件”属性(因此
issue.fields.attachment


希望这有帮助

我今天在1.0.7版上遇到了完全相同的问题:没有找到属性“attachment”,但当我使用它时,实际上找到了它

您是否像我一样,使用
issues=jira.search\u issues()
首先检索问题?由于某种原因,它返回的对象缺少“附件”属性

但是,您可以通过调用
issue=jira.issue(issues[i].key)
来检索特定问题的新对象。此对象将具有“附件”属性(因此
issue.fields.attachment


希望这有帮助

jira中的解析器没有解析出JSON文档中rest响应返回的
附件
键。你需要

issues=jira.search_issues(“受让人在(currentUser())”,字段=[“附件”]

jira中的解析器没有解析出JSON文档中rest响应返回的
附件
键。您需要

issues=jira.search_issues(“受让人在(currentUser())”,字段=[“附件”]

打得好。我想这正是他的问题。@pip是的,我使用的是jira.search\u issue()。但我尝试了你的方法,仍然得到了相同的错误-未找到属性“attachment”。即使我查看原始表单(issue.raw),也找不到附件属性我尝试使用命令issue=jira.search\u issues('project=OPENNLP',startAt=count,maxResults=50,fields='attachment')在对象中包含'attachment'字段。但是attachment属性仍然没有得到includedGood调用。我想这正是他的问题。@pip是的,我正在使用jira.search\u issue()。但我尝试了您的方法,但仍然得到相同的错误-未找到属性“attachment”。即使在查看对象的原始表单(issue.raw)时,也找不到附件属性。我尝试使用命令issue=jira.search\u issues在对象中包含“attachment”字段('project=OPENNLP',startAt=count,maxResults=50,fields='attachment')。但是仍然没有包含附件属性
In [24]: issue=jira.issue('OPENNLP-830')
In [25]: issue.id
Out[25]: '12931716'
In [26]: jira.attachment(12931716)
---------------------------------------------------------------------------
JIRAError                                 Traceback (most recent call last)
/usr/lib/python3.4/site-packages/jira/jirashell.py in <module>()
----> 1 jira.attachment(12931716)
JIRAError: JiraError HTTP 404 url: https://issues.apache.org/jira/rest/api/2/attachment/12931716 details: /tmp/jiraerror-0n8wkhwj.tmp
#!usr/bin/python

from jira import JIRA
import psycopg2
from creating_db import create_db  

def main():
    #Establishing connection with JIRA 
    options = {'server': 'https://issues.apache.org/jira'}
    jira = JIRA(options)
    #Creating the necessary database
    create_db()
    #Connecting to the database
    try:
        conn=psycopg2.connect("dbname='issue_db' host='master' user='hema' password='password'")
    except psycopg2.Error as e:
        print (e)
    cur=conn.cursor ()
    #This command returns an object of type ResultList. ResultList has an attribute called 'total' which gives us the total number of issues filled so far in a given project.
    issue_count=jira.search_issues('project=OPENNLP')
    #Iteratively receiving the issues 
    for count in range(0, issue_count.total,50):
        issue_in_proj = jira.search_issues('project=OPENNLP', startAt = count, maxResults = 50)
        issue_attachment=[issue.fields.attachment for issue in issue_in_proj] # the documentation says its issue.fields.attachment and not attachments
        for i in range( len(issue_in_proj)):
            for j in range(len(issue_attachment[i]):
                cur.execute('''INSERT INTO attachments VALUES(%s,%s)''',  [(issue_id[i],issue_attachment[i][j].id)])
    conn.commit()
    cur.close
    conn.close 

if __name__=="__main__":
    main()