Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/305.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中填写服务请求表单_Python_Python Requests_Jira_Jira Rest Api_Python Jira - Fatal编程技术网

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

如何通过python请求在JIRA中填写服务请求表单,python,python-requests,jira,jira-rest-api,python-jira,Python,Python Requests,Jira,Jira Rest Api,Python Jira,我想在JIRA的服务请求中发布一个表单。为此,我能够进行身份验证并获取cookie。使用cookie,我试图创建一个服务请求,但从服务器上得到400个错误。有人能纠正我的错误吗?感谢您的帮助 在这里发布错误消息。 import requests, logging from requests import Session logging.basicConfig(level=logging.DEBUG) USERNAME = "" PASSWORD = "&quo

我想在JIRA的服务请求中发布一个表单。为此,我能够进行身份验证并获取cookie。使用cookie,我试图创建一个服务请求,但从服务器上得到400个错误。有人能纠正我的错误吗?感谢您的帮助


在这里发布错误消息。
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)