2015-06-25 17 views
2

我不知道這個命令(請求行)拋出的錯誤意味着什麼,並且似乎沒有任何關於它的信息。Python請求庫函數返回u「無法識別的令牌'filspoetfed':期待空值」

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/」, 頭=報頭,AUTH = requests.auth.HTTPDigestAuth( '用戶', '密碼'), 數據=數據)

r.json() 

我嘗試使用請求庫做一個POST請求JIRA,並r.json()JSON響應看起來像這樣...

{u'errorMessages': 
    [u"Unrecognized token 'filspoetfed': was expecting 'null', 'true', 'false' or NaN\n 
    at [Source: [email protected]; line: 1, column: 23]"]} 

以前有人看過這個嗎?在我的JIRA問題/ JSON中沒有屬性'filspoetfed',所以我不明白。我知道唯一的另一種可能性是它在被提交時被轉換成unicode ......但如果這是問題,我不知道如何解決它。我以與JIRA REST api頁面相同的格式來完成此操作。幫助將不勝感激!

+0

請發佈您的代碼... –

+0

@bruno我儘可能多地添加了我可以更清楚地定義問題。 – Ian

+0

也爲解決方案。有同樣的問題 – geudrik

回答

2

我也有類似的問題,並通過改變請求

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

重要的是使用json.dumps(數據),而不是數據,並在頭解決它也包括

'Accept': 'application/json' 

希望它適合你! 祝您有個美好的一天

相關問題