Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
minLevel1
maxLevel6
outlinefalse
stylenone
typelist
printabletrue

...

Description

Original Server State

PATCH payload

Server state after PATCH operation

Response Code

Updating a leaf node

{
"categories": {
"code": "1",
"name": "Children",
"books": [
{
"title": "Matilda",
      "lang": "English",
"price": 200,
"editions": [1988,2000]
}
]
}
}

{
"categories": {
"code": 1,
"name": "Kids"
}
}

{
"categories": {
"code": "1",
"name": "Kids",
"books": [
{
"title": "Matilda",
      "lang": "English",
"price": 200,
"editions": [1988,2000]
}
]
}
}

200 Ok

Updating a leaf and a leaf list

{
"categories": {
"code": "1",
"name": "Children",
"books": [
{
"title": "Matilda",
      "lang": "English",
"price": 200,
"editions": [1988,2000]
}
]
}
}

{
"title": "Matilda",
"editions":[1988, 2000, 2024],
"price": 25
}

{
"categories": {
"code": "1",
"name": "Children",
"books": [
{
"title": "Matilda",
      "lang": "English",
"price": 25,
"editions": [1988,2000,2024]
}
]
}
}

200 OK

Updating a leaf while also adding a new list item with key "title": "The Gruffalo" in the list node books

{
"categories": {
"code": "1",
"name": "Children",
"books": [
{
"title": "Matilda",
      "lang": "English",
"price": 200,
"editions": [1988,2000]
}
]
}
}

{
"books": [
{
"title": "Matilda",
"price": 25
},
{
"title": "The Gruffalo",
"lang": "English",
"authors": ["Julia"],
"editions": [1999],
"price": 15
}
]
}
}

{
"categories": {
"code": "1",
"name": "Children",
"books": [
{
"title": "Matilda",
      "lang": "English",
"price": 200,
"editions": [1988,2000]
}
]
}
}

409 Conflict

Updating leaves in multiple nodes

{
"books": [
{
"title": "Matilda",
      "lang": "English",
"price": 200,
"editions": [1988,2000]
},
{
"title": "The Gruffalo",
"lang": "English",
"authors": ["Julia"],
"editions": [1999],
"price": 15
}
]
}

{
"books": [
{
"title": "Matilda",
"price": 20,
"editions": [2025]
},
{
"title": "The Gruffalo",
"price": 150
}
]
}

{
"books": [
{
"title": "Matilda",
      "lang": "English",
"price": 20,
"editions": [1988,2000,2025]
},
{
"title": "The Gruffalo",
"lang": "English",
"authors": ["Julia"],
"editions": [1999],
"price": 150
}
]
}

200 OK

Examples of PUT operation

Description

Original Server State

PATCH payload

Server state after PATCH operation

Response
Code

Replacing a leaf node

{
"categories": {
"code": "1",
"name": "Children",
"books": [
{
"title": "Matilda",
      "lang": "English",
"price": 200,
"editions": [1988,2000]
}
]
}
}

{
"categories": {
"code": "1",
"name": "Kids",
"books": [
{
"title": "Matilda",
      "lang": "English",
"price": 200,
"editions": [1988,2000]
}
]
}
}

{
"categories": {
"code": "1",
"name": "Kids",
"books": [
{
"title": "Matilda",
      "lang": "English",
"price": 200,
"editions": [1988,2000]
}
]
}
}

200 OK

Replacing a leaf node and entire list

{
"categories": {
"code": "1",
"name": "Children",
"books": [
{
"title": "Matilda",
      "lang": "English",
"price": 200,
"editions": [1988,2000]
}
]
}
}

{
"categories": {
"code": "1",
"name": "Kids"
}
}

{
"categories": {
"code": "1",
"name": "Kids"
]
}
}

200 OK

Using PUT to create a new list

{
"categories": {
"code": "1",
"name": "Children"
}
}

{
"categories": {
"code": "1",
"name": "Kids",
"books": [
{
"title": "Matilda",
      "lang": "English",
"price": 200,
"editions": [1988,2000]
}
]
}
}

{
"categories": {
"code": "1",
"name": "Kids",
"books": [
{
"title": "Matilda",
      "lang": "English",
"price": 200,
"editions": [1988,2000]
}
]
}
}

201 Created

Using PUT to add a new list item

{
"categories": {
"code": "1",
"name": "Children",
"books": [
{
"title": "Matilda",
      "lang": "English",
"price": 200,
"editions": [1988,2000]
}
]
}
}

{
"categories": {
"code": "1",
"name": "Children",
"books": [
{
"title": "Matilda",
      "lang": "English",
"price": 200,
"editions": [1988,2000]
},
{
"title": "The Gruffalo",
"lang": "English",
"authors": ["Julia"],
"editions": [1999],
"price": 15
}
]
}
}

{
"categories": {
"code": "1",
"name": "Children",
"books": [
{
"title": "Matilda",
      "lang": "English",
"price": 200,
"editions": [1988,2000]
},
{
"title": "The Gruffalo",
"lang": "English",
"authors": ["Julia"],
"editions": [1999],
"price": 15
}
]
}
}

201 Created

Replacing an entire list with a new list item

{
"categories": {
"code": "1",
"name": "Children",
"books": [
{
"title": "Matilda",
      "lang": "English",
"price": 200,
"editions": [1988,2000]
},
{
"title": "The Gruffalo",
"lang": "English",
"authors": ["Julia"],
"editions": [1999],
"price": 15
}
]
}
}

{
"categories": {
"code": "1",
"books": [
{
"title": "New Book",
      "lang": "English",
"price": 0,
"editions": [2025]
}
]
}
}

{
"categories": {
"code": "1",
"books": [
{
"title": "New Book",
      "lang": "English",
"price": 0,
"editions": [2025]
}
]
}
}

200 OK

Replacing entire leaf list using PUT

{
"categories": {
"code": "1",
"name": "Children",
"books": [
{
"title": "Matilda",
      "lang": "English",
"price": 200,
"editions": [1988,2000]
}
]
}
}

{
"categories": {
"code": "1",
"name": "Children",
"books": [
{
"title": "Matilda",
      "lang": "English",
"price": 200,
"editions": [2025]
}
]
}
}

{
"categories": {
"code": "1",
"name": "Children",
"books": [
{
"title": "Matilda",
      "lang": "English",
"price": 200,
"editions": [2025]
}
]
}
}

200 OK