Cole_McDonald
5 years agoProfessor
REST API Patch issue...
Has anyone had any success using the v2 of the REST API to push a PATCH to add a customer property to an object (in this case /device/groups/##### without wiping out any other custom properties tha...
- Anonymous5 years ago
The HTTP verb you use will determine that. If I want to update existing properties, i use PUT. If i want to create a new one, i use POST.
These examples are for devices, but it's similar for groups:
To create a new property on device 43 called "my.new.property", I POST to "/device/devices/43/properties/" with the following payload:
{ "name": "my.new.property", "value": "value of the property" }
If i repeat the same action, i get this response:
{ "errorMessage": "Property(name=my.new.property) already exists in device(id=43)", "errorCode": 1400, "errorDetail": null }
So, to update that property with a new value, I do a PUT to "/device/devices/43/properties/my.new.property" with the following payload:
{"value":"Star Wars!"}
More reading: https://medium.com/backticks-tildes/restful-api-design-put-vs-patch-4a061aa3ed0b