Issue with Set Commands - Removing existing data
Steps to reproduce
I am trying to update a couple fields in the Flexible assett traits, however if I run a set command with only those fields I want to update. The rest of the information is deleted. According to the Wiki, the rest of them should be left alone.
Expected behavior
Before JSON Data: "name": "Corporate Network 10.12.48.0/24", "traits": { "name": "Corporate Network", "subnet": "10.12.48.0/24", "dhcp-scope": "10.12.48.100-200", "location": { "type": "Locations", "values": [ "@{resource-url=https://integratedit.itglue.com/3673958/locations/5160533; id=5160533; name=Main; address-1=1 Decibel Dr.; city=Waltham; organization-name=XYZ Company}" ] }, "firewall": { "type": "Configurations", "values": [ "@{resource-url=https://integratedit.itglue.com/3673958/configurations/27468761; id=27468761; name=IIT Firewall; organization-name=XYZ Company; configuration-type-name=EDGE - Firewall/Router}" ] }, "switch-es": { "type": "Configurations", "values": [ "@{resource-url=https://integratedit.itglue.com/3673958/configurations/27468760; id=27468760; name=HP-2530-24G; organization-name=XYZ Company; configuration-type-name=LAN - Switch}", "@{resource-url=https://integratedit.itglue.com/3673958/configurations/27468762; id=27468762; name=HP-2530-48G-PoEP; organization-name=XYZ Company; configuration-type-name=LAN - Switch}" ]
Actual behavior
Running Update:(No changes in reality) { "type": "flexible-assets", "attributes": { "traits": { "name": "Corporate Network", "subnet": "10.12.48.0/24" } } } VERBOSE: PATCH https://api.itglue.com/flexible_assets/12243164 with -1-byte payload VERBOSE: received 521-byte response of content type application/vnd.api+json; charset=utf-8
** JSON Data after PATCH command:
"attributes": { "organization-id": 3673958, "organization-name": "XYZ Company", "resource-url": "https://integratedit.itglue.com/3673958/assets/120451-lan/records/12243164", "restricted": false, "my-glue": false, "flexible-asset-type-id": 120451, "flexible-asset-type-name": "LAN", "name": "Corporate Network 10.12.48.0/24", "traits": { "name": "Corporate Network", "subnet": "10.12.48.0/24" },
What am I missing with the Set command? According to the IT Glue API - this is expected behavior as they mention any traits you dont pass will be deleted. Is the documentation wrong and I do need to pass all traits back?
The Github wiki is wrong. Any field you omit will be deleted when updating. Cannot remember where this is stated but that is the case.
I am having the exact same problem and it is a show-stopper for me. I too wanted to only update a single 'trait', so when I only included that one trait all other fields were deleted. Understanding what @ecspresso just described, my problem still isn't fixable. In my 'traits' I have a file upload field. So when I try to update that flexible asset and include the file upload field (that I have named 'artifacts'), I get this error:
Set-ITGlueFlexibleAssets : {"errors":[{"status":422,"title":"attachment[content] is required for upload","source":{"pointer":"/data/attributes/attachment/content"}}]} At line:1 char:1
- Set-ITGlueFlexibleAssets -data $controls[1] -id $controls[1].id
-
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Set-ITGlueFlexibleAssets
How am I to update this flexible asset, change the value of one of the string fields, but not also wipe out the attachment?
Found the comment @ecspresso was referencing at https://api.itglue.com/developer/#flexible-assets-update
"Any traits you don't specify will be deleted. Passing a null value will also delete a trait's value."
This looks like something that might not be fixable by anyone other than the ITGlue people.
Found the comment @ecspresso was referencing at https://api.itglue.com/developer/#flexible-assets-update "Any traits you don't specify will be deleted. Passing a null value will also delete a trait's value." This looks like something that might not be fixable by anyone other than the ITGlue people.
I got around it by reading in the entire trait - then manipulating it. Some only required the "ID" to be passed back to be valid (the JSON may return more data).
Then setting the "new" trait values (containing all the previous and the updates).
Yeah, that's what I assumed you were doing. Unfortunately, that won't work for me because of the file attachment. Thanks for replying so quickly.