【问题标题】:Assign a existing jira ticket/issue to a user in Python在 Python 中将现有的 jira 票证/问题分配给用户
【发布时间】:2022-10-26 00:25:02
【问题描述】:

我正在尝试使用 python 分配现有的 jira 票证。尝试了以下方法,但没有一个有效。我可以添加 cmets 但不能分配问题

    #Method 1 Using Jira library - Getting JiraError HTTP None, text list index out of range
    from jira import JIRA
    jira_connection = JIRA(basic_auth=(username,password),server)
    issue = jira_connection.issue('100')
    jira_connection.assign_issue(issue,user_name)

    #Tried below way as well 
    issue.update(assignee={'accountId':'natash5'})


    #Method 2 Using Servicedesk - the update_issue_field function was empty in the source code
    from atlassian import ServiceDesk
    sd = ServiceDesk(url= "")
    sd.update_issue_field('100',{'assignee':'user_name')

    #Method 3 Soap API - SAXParse exception invalid token
    from suds import Client
    cl = Client(url)
    auth = cl.service.login(username,password)

【问题讨论】:

    标签: python python-3.x jira jira-rest-api python-jira


    【解决方案1】:
    import requests
    from requests.auth import HTTPBasicAuth
    import json
    
    url = "https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/assignee"
    
    auth = HTTPBasicAuth("email@example.com", "<api_token>")
    
    headers = {
        "Accept": "application/json",
        "Content-Type": "application/json"
    }
    
    payload = json.dumps( {
        "accountId": "5b10ac8d82e05b22cc7d4ef5"
    } )
    
    response = requests.request(
        "PUT",
        url,
        data=payload,
        headers=headers,
        auth=auth
    )
    
    print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))
    

    我遇到了同样的问题,自己使用端点而不是 - https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-assignee-put 如果您有兴趣,我正在整理一个包含大量此类内容的存储库,以及完成任务的方法。它还有很多东西需要整理,所以承认这是一个测试版:) https://github.com/dren79/JiraScripting_public

    【讨论】:

      猜你喜欢
      • 2014-11-05
      • 2014-09-30
      • 1970-01-01
      • 2023-03-28
      • 1970-01-01
      • 2014-10-02
      • 1970-01-01
      • 2018-01-08
      • 2020-08-19
      相关资源
      最近更新 更多