在CouchDB中设置显式响应Content-Type

5
我正在寻找一种设置couchdb响应的Content-Type的方法。
我已经使用application/json作为Content-TypeAccept请求标头,以POST方式发送了JSON。但是当我调用该文档的GET时,它返回带有text/plain; charset=utf-8Content-Type的JSON响应。我期望得到的是application/json作为它的Content-Type
如何做到这一点? POST
  • URL : 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"}]}
  • 请求标头: Accept : application/json Content-Type : application/json
GET
  • URL : 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 Content-Type : text/plain; charset=utf-8
除此之外,我也尝试了PUT然后GET,但结果是相同的。
CouchDB版本:1.6.1
1个回答

5

我找到了答案。

当我使用 Accept:application/json 请求头调用 GET 方法时,它起作用了! 该死!我怎么会错过这个呢!

无论如何,如果您有任何不同的解决方案,请随时发表。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接