Configuring an explicit Content-Type response in CouchDB

I am looking for a way to set Contet-Typecouchdb for an answer.

I have POSTJSON using request headers Content-Typeand Accepthow application/json. But when I call GETfor this document, it returns a JSON response with Content-Type text/plain; charset=utf-8. I expect to get application/jsonhow Content-Type.

How can i do this?

Post

  • URL: http: // localhost: 5984 / hotel_staticdata
  • Request body: {"_id":"test-hotel-stat-data","content":[{"hotelcode": "AMB3_LON","hotelname": "Ambassadors Bloomsbury"},{"hotelcode": "ALE1_LON","hotelname": "Alexandra"},{"hotelcode": "ALE1_LON","hotelname": "Alexandra"}]}
  • Request Header: Accept: application / json Content-Type: application / json

Get

  • URL: http: // localhost: 5984 / hotel_staticdata / test-hotel-stat-data
  • Answer body: {"_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"}]}
  • Response headers: Content-length: 249 Content-Type: text / plain; encoding = UTF-8

PUT, GET, .

  • CouchDB: 1.6.1
+4
1

.

GET Accept:application/json. ! ! !

, - , .

+5

Source: https://habr.com/ru/post/1671569/


All Articles