Python请求库发布函数返回u“无法识别的标记'filspoetfed':预期为空”

Ian*_*Ian 3 python json jira http-post

我不知道此命令(请求行)引发的错误是什么意思,而且似乎没有关于它的在线信息。

 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'}
Run Code Online (Sandbox Code Playgroud)

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

 r.json()
Run Code Online (Sandbox Code Playgroud)

我尝试使用请求库向JIRA发出发布请求,并且对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]"]}
Run Code Online (Sandbox Code Playgroud)

有人看过吗?我的JIRA问题/ JSON中没有属性“ filspoetfed”,所以我不明白。据我所知,唯一的另一种可能性是它在提交时就被转移到unicode中……但是,如果那是个问题,我不知道该如何解决。我这样做的格式与JIRA REST api页面上的格式相同。帮助将不胜感激!

Fer*_*ila 6

我有一个类似的问题,并通过更改请求解决了

requests.post(url, data = json.dumps(data),auth=HTTPBasicAuth(username, password), headers= header)
Run Code Online (Sandbox Code Playgroud)

重要的是使用json.dumps(data)代替data,并且在标头中也包含

'Accept': 'application/json'
Run Code Online (Sandbox Code Playgroud)

希望对你有帮助!祝你今天愉快