Delete attribute (like custom var) via API

#1

Hi,

I’ve added a custom var via api to an already existing host, like this:
curl -k -s -u user:pass -H 'Accept: application/json' -X POST 'https://127.0.0.1:5665/v1/objects/hosts/TEST_HOST' -d '{ "attrs": {"vars.testvar.0" : "Something"} }

This was working great, but how can I remove this custom var?

(Aflatto) #2

Have you tried

curl -k -s -u user:pass -H ‘Accept: application/json’ -X POST ‘https://127.0.0.1:5665/v1/objects/hosts/TEST_HOST’ -d '{ “attrs”: {“vars.testvar.0” : null} }

#3

Yes. The custom var, then, is still there, but is empty. Unfortuately not deleted…

(Aflatto) #4

did you try DELETE instead of POST ?

Be careful as it might delete the whole object

#5

Unfortunately also isn’t woking. As you expected, it will only try to delete the hole object. Luckily it isn’t able to do this, because everything except the custom var was created using the config. And thats why I’m only getting this:
Object cannot be deleted because it was not created using the API