Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

If the user modifies an existing list item and along with that adds a new list item in the payload then once the request is executed the user receives a 200-response code. But upon verifying the data after the request is executed it is seen that only

Expand

Correct parent node xpath: /bookstore/categories[@code=1]

Incorrect JSON payload with newly added list item with title: Book 2

Code Block
{
  "books": [
    {
      "title": "Matilda",
      "lang": "French",
      "editions": [2025]
    },
    {
      "title": "Book 2",
      "lang": "English",
      "authors": ["Test"],
      "editions": [2000]
    }
  ]
}

...

Expand
Code Block
[
  {
    "book-store:books": {
	  "title": "Matilda",
      "lang": "French",
      "authors": ["Roald Dahl"],
      "editions": [2025]
    }
  }
]

It can be seen that only the existing list item, i.e. title: Matilda is replaced. Whereas the newly added list item with title: Book 2 is not added but user received a 200-response code.

Expected Behavior

  • This is a user error as request is in itself wrong, because it tries to add a new list item to a list.

  • CPS provides a separate endpoint to Add a list element

  • So, such a scenario should be handled by throwing an exception from the API instead of returning a successful response.

  • Add support to Add list elements using Replace a node API

  • Throw appropriate error message when a non-existing list item is sent as part of the payloadBased on the RESTful principles a PUT operation should completely rewrite the data in the database with the new data provided in the payload.

  • So, the expected behavior is to replace all the data of the existing data node and if any new data node is provided as part of the request, then it should be added as a new entity. And the response code should be changed to 204-Created.

Based on the above observations the correct response after data is Replaced should be as follows

Expand
Code Block
{
  "books": [
    {
      "title": "Matilda",
      "lang": "French",
      "editions": [2025]
    },
    {
      "title": "Book 2",
      "lang": "English",
      "authors": ["Test"],
      "editions": [2000]
    }
  ]
}

Proposed/Accepted Solutions

...