The patch api does not seem to work for adding category options to categories. I have not tested other similar list properties.
Here’s an example request (you may need to change the category option uid in case it’s already been added)
curl -X PATCH -H "Content-Type: application/json-patch+json" -d '[{ "op": "add", "path": "/categoryOptions/-", "value": {"id": "K4gwuiVvW3z"} }]' 'https://play.im.dhis2.org/stable-2-40-4-1/api/categories/gtuVl6NbXQV' -u admin:district
Error message is as follows:
{“httpStatus”:“Conflict”,“httpStatusCode”:409,“status”:“ERROR”,“message”:“org.hibernate.PropertyValueException: not-null property references a null or transient value : org.hisp.dhis.category.Category.uid”}
A similar request pattern to update a data element group does seem to work though (again, may need to modify the DE uid to make sure it’s not previously been added):
curl -X PATCH -H "Content-Type: application/json-patch+json" -d '[{ "op": "add", "path": "/dataElements/-", "value": {"id": "ONCHOLF0022"} }]' 'https://play.im.dhis2.org/stable-2-40-4-1/api/dataElementGroups/qfxEYY9xAl6' -u admin:district
2 posts - 2 participants