官术网_书友最值得收藏!

Principle 4 – Resources can have multiple representations

A key feature of a resource is that it may be represented in a different format from the one in which it is stored. Thus, it can be requested or created in different representations. As long as the specified format is supported, the REST-enabled endpoint should use it. In the preceding example, we posted an XML representation of a watch item, but if the server had supported the JSON format, the following request would have been valid as well:

POST /categories/watches HTTP/1.1
Content-Type: application/json
Host: www.mycatalog.com

{
  "watch": {
    "id": ""watch-abc"",
    "brand": "...",
    "price": {
      "-currency": "EUR",
      "#text": "100"
    }
  }
}
HTTP/1.1 201 Created
Content-Type: application/json
Location: http://mycatalog.com/categories/watches/watch-abc   
主站蜘蛛池模板: 文水县| 乐清市| 镇赉县| 淮北市| 星座| 安阳市| 墨江| 溧阳市| 遂平县| 麻城市| 海口市| 四会市| 石门县| 庆阳市| 玛纳斯县| 大港区| 施甸县| 韩城市| 东莞市| 安陆市| 临安市| 安新县| 凤冈县| 咸阳市| 贵阳市| 宜章县| 福清市| 邢台县| 清远市| 阿巴嘎旗| 广河县| 裕民县| 芒康县| 安吉县| 乐昌市| 包头市| 盈江县| 明光市| 盈江县| 锦州市| 桂东县|