...
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: Incorrect JSON payload with newly added list item with
|
...
Expand | ||
---|---|---|
|
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.
Scenario 2: API executes the request with incorrect payload
Another user induced error can occur when the user tries to make changes to the key leaf node, which in the current example is "title"
. If the key is modified, for example title "Matilda"
changed to "Incorrect Book Name"
, the request should fail because there is no such node present in the database.
But if such an error is intentionally induced to test the functionality of the API, it is seen that the request gets executed with an incorrect payload and the user receives a 200-response code.
...
Correct parent node xpath: /bookstore/categories[@code=1]
...
Expected Behavior
Based 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 | ||
---|---|---|
|
Proposed/Accepted Solutions
Info |
---|
WIP |