我正在寻找一种方法来设置 Contet-Type
对于 couchdb 响应。
我有 POST
使用 Content-Type
的 JSON和 Accept
请求 header 为 application/json
.但是当我调用 GET
对于该文档,它返回带有 Content-Type
的 JSON 响应text/plain; charset=utf-8
.我期待的是得到 application/json
因为它是 Content-Type
.
我怎样才能做到这一点?
发布
{"_id":"test-hotel-stat-data","content":[{"hotelcode": "AMB3_LON","hotelname": "Ambassadors Bloomsbury"},{"hotelcode": "ALE1_LON","hotelname": "Alexandra"},{"hotelcode": "ALE1_LON","hotelname": "Alexandra"}]}
接受:应用程序/json
内容类型:应用程序/json
获取
{"_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"}]}
内容长度:249
内容类型:文本/纯文本;字符集=utf-8
而不是这个,我尝试了 PUT 然后 GET ,但结果是一样的。
最佳答案
我得到了答案。
当我用 Accept:application/json
调用 GET 时请求 header 。有用!
该死!我怎么错过了!
无论如何,如果您有任何不同的解决方案,请随时发布。
关于json - 在 CouchDB 中设置显式响应 Content-Type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42620627/