B.2.1. 创建新的数据资源

要在“libaray”资源中创建新的“artist”资源,客户端可能会发送以下请求:

  1. POST /restconf/data/example-jukebox:jukebox/library HTTP/1.1
  2. Host: example.com
  3. Content-Type: application/yang-data+json
  4. {
  5. "example-jukebox:artist" : [
  6. {
  7. "name" : "Foo Fighters"
  8. }
  9. ]
  10. }

如果资源已创建,则服务器可能会作出如下响应:

  1. HTTP/1.1 201 Created
  2. Date: Thu, 26 Jan 2017 20:56:30 GMT
  3. Server: example-server
  4. Location: https://example.com/restconf/data/example-jukebox:jukebox/library/artist=Foo%20Fighters
  5. Last-Modified: Thu, 26 Jan 2017 20:56:30 GMT
  6. ETag: "b3830f23a4c"

在“jukebox”中为该艺术家创建新的“album”资源资源,客户端可能会发送以下请求:

  1. POST /restconf/data/example-jukebox:jukebox/library/artist=Foo%20Fighters HTTP/1.1
  2. Host: example.com
  3. Content-Type: application/yang-data+xml
  4. <album xmlns="http://example.com/ns/example-jukebox">
  5. <name>Wasting Light</name>
  6. <year>2011</year>
  7. </album>

如果资源已创建,则服务器可能会作出如下响应:

  1. HTTP/1.1 201 Created
  2. Date: Thu, 26 Jan 2017 20:56:30 GMT
  3. Server: example-server
  4. Location: https://example.com/restconf/data/example-jukebox:jukebox/library/artist=Foo%20Fighters/album=Wasting%20Light
  5. Last-Modified: Thu, 26 Jan 2017 20:56:30 GMT
  6. ETag: "b8389233a4c"