Hello,
I’m trying to bulk update assets in our Freshservice with "warranty_expiry_date" from HP and hitting two main problems. One of them is specific to powershell, the second is quite general regarding how asset properties are structured. Hoping someone can help?
1) When checking the documentation for updating assets, in the sample code the properties in the "type_fields" section has the suffix "_25", like "product_25". Where does the "_25" come from? What’s that ID doing there? It doesn’t seem to be the ID of the asset and I can’t find any information where it comes from? When checking my own environment I have "_26000456017" and not "_25". But how can I programatically know what to have there when updating the asset if I don’t know what it’s supposed to be? Or is it the ID of the Freshservice instance, in which case it should be the same for all assets (which it appears to be)
2) When doing this using powershell I'm getting "415 - Unsupported media type" which is the general error for "invalid JSON". But my JSON looks ok. I don't know if there are any fields that are "required" since the documentation doesn’t detail anything, I thought just posting the asset ID and name would be sufficient but I don't know why I'm getting the error?
My powershell looks like this:
$FDApiKey=" $pair = "$($FDApiKey):$($FDApiKey)"
$bytes = )System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = )System.Convert]::ToBase64String($bytes)
$basicAuthValue = "Basic $base64"
$FDHeaders = @{ Authorization = $basicAuthValue }
ANet.ServicePointManager]::SecurityProtocol = cNet.SecurityProtocolType]::TLS12
$URL = "https://>ourdomain].freshservice.com/api/v2/assets"
$AssetAttributes = ""
$AssetAttributes = @{}
$AssetAttributes.Add('id', '26000338114')
$AssetAttributes.Add('name', '5CD9516D60')
$AssetAttributes.Add('asset_tag', 'ASSET-2480')
$AssetAttributes = @{'asset' = $AssetAttributes}
$JSON = $AssetAttributes | ConvertTo-Json
Invoke-RestMethod -Method Post -Uri $URL -Headers $FDHeaders -Body $JSON
But nope :(
I’m not a developer used to JSON/Curl so I may have missed something obvious here :(