2014-04-22 24 views
0

我運行的Python 2.7.5和Win7的CouchDB的1.3.0(64),當我保存一個JSON文件得到錯誤信息:couchdb.http.ServerError:(415,(u'bad_content_type',u'Content-Type必須是application/json'))。 ...內容類型必須是application/json的錯誤使用Python 2.7.5和沙發DB 1.30

kkey = 'schluessel' 
vvalue = 'Wert' 
str1 = [kkey , vvalue] 
str2 = json.dumps(str1) 
oup.write(str2 + '\n') 
# the line above gives: ["schluessel", "Wert"] 
doc_id, doc_rev = db.save(str2) 

感謝您的幫助

回答

0

起初你想保存不JSON文檔,這是由JSON對象類型表示,但JSON數組這不是一個文件都沒有。試試這個:

kkey = 'schluessel' 
vvalue = 'Wert' 
str1 = {kkey: vvalue} 
str2 = json.dumps(str1) 
oup.write(str2 + '\n') 
# the line above gives: {"schluessel": "Wert"} 
doc_id, doc_rev = db.save(str2) 
+0

大,這個工程。 Muchas Gracias – user3560278

相關問題