Python 请求库 post 函数返回 u"Unrecognized token 'filspoetfed': was expecting null"

Python request library post function returning u"Unrecognized token 'filspoetfed': was expecting null"

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

 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)

 r.json()

我尝试使用请求库向 JIRA 发出 post 请求,JSON 对 r.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]"]}

有人看过这个吗?我的JIRAissue/JSON里没有属性'filspoetfed',所以没看懂。据我所知,唯一的另一种可能性是它在提交时被转换为 unicode ......但如果这是问题,我不知道如何解决它。我以与 JIRA REST api 页面上相同的格式执行此操作。将不胜感激!

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

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

重要的是使用 json.dumps(data) 而不是数据,在 header 中还包括

'Accept': 'application/json'

希望对你有用! 祝你有美好的一天