API Groovy HttpPatch?
Is it possible to do an HttpPatch, or to use the PATCH verb, when updating devices?
I looked over on one of the LM pages for updataing devices with the API and as usual, most of the examples were in Python, but PUT did have one Groovy example, but PATCH did not. I’ve seen mention somewhere that at some point PATCH would be supported, wondering if it is or not.
I ended up getting my script working with a Get (so I dont lose all my device custom settings etc) and then changing the autoBalancedCollectorGroupId value, and then doing a PUT and it worked, and I didnt lose any of my custom properties. And I have a working filter all set up to run it against a target set of devices.
But still, I would rather just patch the fields I want without risk. I’m wondering if thats possible, or if GET/tweak/PUT is still the main go-to?
- Anonymous9 months ago
Up to personal preference at that point. It should work either way since you already have the object in memory. Technically, it’s a bit less efficient to do a PUT since you’re putting more data than what needs to be changed, but the PUT also doesn’t change anything if nothing needs to be changed.
I personally would do PATCH because that way i know my code is only touching the thing i want to change (easier to tell what the code is changing). PUT is technically more idempotent.