如何通过python请求在JIRA中填写服务请求表

时间:2020-10-06 18:34:58

标签: python python-requests jira jira-rest-api python-jira

我正在尝试在JIRA的服务请求中发布表格。为此,我可以进行身份​​验证并获取Cookie。使用cookie,我试图创建一个服务请求,但是从服务器中收到了400个错误。有人可以纠正我在做什么错误吗?任何帮助表示赞赏。

enter image description here

enter image description here

import requests, logging
from requests import Session

logging.basicConfig(level=logging.DEBUG)
USERNAME = ""
PASSWORD = ""
s = Session()
base_url = "https://jira.company.com"
session_response = s.post(base_url + "/rest/auth/1/session",
                          json={"username": USERNAME, "password": PASSWORD})
# create the issue with this url https://jira.company.com/servicedesk/customer/portal/1/create/20
jira_post_url = base_url + "/servicedesk/customer/portal/1/create/20"
cookie = session_response.cookies
token = dict(session_response.cookies).get("atlassian.xsrf.token")
headers = {"Content-Type": "application/json"}
data = {
    'atl_token': token,
    'projectId': 12704,
    'reporter': 'testuser@gmail.com',
    'customfield_11615': 'test1234',
    'customfield_11526': '5/Oct/20',
    'priority': '3',
    'customfield_11528': '',
    'sd-kb-article-viewed': False
}
response = requests.request("POST", jira_post_url, data=json.dumps(data), cookies=cookie)
print(response.status_code)

0 个答案:

没有答案