如何通过python请求在JIRA中填写服务请求表单
我想在JIRA的服务请求中发布一个表单。为此,我能够进行身份验证并获取cookie。使用cookie,我试图创建一个服务请求,但从服务器上得到400个错误。有人能纠正我的错误吗?感谢您的帮助如何通过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
在这里发布错误消息。
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)