...
Updating all data trees under an anchor with root node xPath "/"
Code Block title CURL request to update multiple leaves across multiple data trees collapse true curl --location --request PATCH 'http://localhost:8080/cps/api/v1/dataspaces/testDataspace/anchors/sample/nodes?xpath=%2F' --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic Y3BzdXNlcjpjcHNyMGNrcyE=' --header 'Cookie: JSESSIONID=node0iyclt1syzfqj28jzo5qc5gks1.node0' \ --data '{ "multiple-data-tree:interface-A": { "host-name": "host-A", //value to be updated "interface": [ { "name": "Interface-A", "address": "10.10.10.100", //value to be updated "subnet-mask": "255.255.255.25", //value to be updated "enabled": false } ], "domain": "true" }, "multiple-data-tree:interface-B": { "interface": [ { "name": "Interface-B", "address": "10.10.10.100", //value to be updated "subnet-mask": "255.255.255.0" //value to be updated } ] } }'
Response: 500 Server Error
Code Block collapse true { "status": "500 INTERNAL_SERVER_ERROR", "message": "could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.DataException: could not execute statement", "details": "Check logs for details." }
Reason: The following scenario would fail because CPS Patch operation only supports updating multiple leaves under one container node at a time. And here when we try to update multiple leaves present in two different containers the operations fails.
On performing Get operation we get the following JSON data, here none of the leaves are updatedCode Block collapse true [ { "int:interface-A": { "domain": "false", "host-name": "host", "interface": [ { "name": "Interface-A", "address": "10.10.10.1", "enabled": false, "subnet-mask": "255.255.255.0" } ] } }, { "int:interface-B": { "interface": [ { "name": "Interface-B", "address": "10.10.10.1", "subnet-mask": "255.255.255.0" } ] } } ]
Updating the data trees individually, leads to successful updation
When updating multiple leaves present under individual data nodes the operation successfully executes.Code Block title CURL request to update leaves under container data node collapse true curl --location --request PATCH 'http://localhost:8080/cps/api/v1/dataspaces/testDataspace/anchors/sample/nodes?xpath=%2F' \ --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic Y3BzdXNlcjpjcHNyMGNrcyE=' --header 'Cookie: JSESSIONID=node0iyclt1syzfqj28jzo5qc5gks1.node0' \ --data '{ "int:interface-A": { "domain": "true", //value to be updated "host-name": "Host-A" //value to be updated } }'
Response 200 OK
Code Block title Updated data after making get request collapse true [ { "int:interface-A": { "domain": "true", //updated "host-name": "Host-A", //updated "interface": [ { "name": "Interface-A", "address": "10.10.10.200", "enabled": true, "subnet-mask": "255.255.255.0" } ] } } ]
Code Block title CURL request to update leaves of one list item in a list data node collapse true curl --location --request PATCH 'http://localhost:8080/cps/api/v1/dataspaces/testDataspace/anchors/sample/nodes?xpath=%2Finterface-B' \ --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic Y3BzdXNlcjpjcHNyMGNrcyE=' --header 'Cookie: JSESSIONID=node0iyclt1syzfqj28jzo5qc5gks1.node0' \ --data '{ "int:interface": { "name": "Interface-B", "address": "10.10.10.200", //value to be updated "subnet-mask": "255.255.255.10" //value to be updated } }'
Response 200 OK
Code Block title Updated data after making get request collapse true [ { "int:interface-B": { "interface": [ { "name": "Interface-B", "address": "10.10.10.200", //updated "subnet-mask": "255.255.255.10" //updated } ] } } ]
...