Python请求库post函数返回u“无法识别的标记'filspoetfed':应为null”

2024-10-04 11:30:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我不知道这个命令(请求行)抛出的错误意味着什么,而且网上似乎也没有关于它的任何信息。在

 data = {
....:        'fields':
....:            {
....:            'environment': '- \\n- Repeated : 0 times',
....:            'description': '',
....:            'summary': 'Fill in Something',
....:            'project': {
....:                        "key": "QABL"
....:                 },
....:            'assignee': 'qa-auto',
....:            'issuetype': 'Bug',
....:            'priority': 'Major'
....:            }
....:        }

print header
{'content-type': 'application/json'}

r = requests.post("https://jira.some-company.net/rest/api/latest/issue/", headers=header, auth=requests.auth.HTTPDigestAuth('user', 'password'), data=data)

^{pr2}$

我试图使用请求库对JIRA执行post请求,对r.JSON()的JSON响应如下。。。在

 {u'errorMessages': 
    [u"Unrecognized token 'filspoetfed': was expecting 'null', 'true', 'false' or NaN\n 
    at [Source: org.apache.catalina.connector.CoyoteInputStream@10758d77; line: 1, column: 23]"]}

有人见过这个吗?我的JIRA issue/JSON中没有属性'filspoetfed',所以我不明白。据我所知,唯一的另一种可能性是,当它提交时,它会被转换成unicode……但如果这就是问题所在,我不知道如何解决它。我用和JIRA restapi页面上相同的格式来做这个。我们将非常感谢您的帮助!在


Tags: 命令auth信息jsonfieldsdataenvironment错误
1条回答
网友
1楼 · 发布于 2024-10-04 11:30:46

我遇到了一个类似的问题,通过更改请求来解决它

requests.post(url, data = json.dumps(data),auth=HTTPBasicAuth(username, password), headers= header)

重要的是使用json.dumps文件(数据)而不是数据,并且在标题中也包括

^{pr2}$

希望对你有用! 祝你今天愉快

相关问题 更多 >