2017-03-06 78 views
4

我正在尋找一種方法來設置用於couchdb響應的Contet-Type在CouchDB中設置顯式響應內容類型

我有POST JSON使用Content-TypeAccept請求標頭爲application/json。但是當我爲該文檔調用GET時,它返回的JSON響應爲Content-Typetext/plain; charset=utf-8。我期待的是application/json,因爲它是Content-Type

我該怎麼做?

POST

  • 網址:http://localhost:5984/hotel_staticdata
  • 請求正文: {"_id":"test-hotel-stat-data","content":[{"hotelcode": "AMB3_LON","hotelname": "Ambassadors Bloomsbury"},{"hotelcode": "ALE1_LON","hotelname": "Alexandra"},{"hotelcode": "ALE1_LON","hotelname": "Alexandra"}]}
  • 請求報頭: 接受:應用/ JSON 內容類型:應用程序/ JSON

GET

  • 網址:http://localhost:5984/hotel_staticdata/test-hotel-stat-data
  • 響應體:{"_id":"test-hotel-stat-data","_rev":"3-6c6e26cd5690794886a8dc65308bf078","content":[{"hotelcode":"AMB3_LON","hotelname":"Ambassadors Bloomsbury"},{"hotelcode":"ALE1_LON","hotelname":"Alexandra"},{"hotelcode":"ALE1_LON","hotelname":"Alexandra"}]}
  • 響應頭: 的Content-Length:249 內容類型:text/plain的; charset = utf-8

取而代之,我嘗試了PUT,然後GET,但結果是一樣的。

  • CouchDB的版本:1.6.1

回答

5

我得到了答案。

當我用Accept:application/json請求標頭調用GET時。有用! 該死!我怎麼錯過了它!

無論如何,如果您有任何不同的解決方案,請隨時張貼。