• 0

REST API Patch issue...

Cole McDonald


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 that have already been set?

We've run into a curious behavior while trying to add a property to feed out integration to our ticketing system.  It seems to replace the whole of the custom properties object, not just the child object within the customproperties level of the json:

{ `"customProperties`" : [{
        `"name`"  : `"connectwisev2.companyid`",
        `"value`" : `"$($integrationID.TrimEnd())`"

We had 2-3 other properties in there that disappeared after patching.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
  • Administrators

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.