Skip to main content

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 :(

have you solve this issue? face same issue related game project of APK...

 


Unfortunately no I haven’t. And even more unfortunately, Freshservice wasn’t that helpful since they don’t really seem to like Powershell and noone there could help me either.

So I ended up exporting everything to Excel CSV and matching everything there, exporting to CSV that I then imported to Fresh so it updated the assets properly.


oky thank you soo much i was worried client project of apks in this matter but i found another way 


Hi @stoff75,
 

Greetings!

  1. 25 in the API documentation refers to the asset_type ID. You can fetch the list of asset types and their respective IDs for your account by calling this API: https://domain.freshservice.com/api/v2/asset_types?per_page=100

  1. We have a few sample PowerShell codes to call our REST APIs mentioned here: https://support.freshservice.com/en/support/discussions/topics/312085

You may be getting this error as the ‘'Content-Type'attribute’ is missing in the headers. Could you add it to your PowerShell script and check?

"Content-Type" =  “application/json”

 

Please try and let us know if the issue persists.

 

Warm Regards,

Sanofar
Team Freshservice


oky thank you soo much i was worried client project of mod apk in this matter but i found another way 

For free APK game projects, you can search on free game websites.


I’m not sure if you have seen this yet, but Flycast Partners actually built out a free Powershell module that is specific to FreshService. It targets the v2 API and I have used it to create assets with great success

https://www.flycastpartners.com/freshworks-freshservice-powershell-api-library/

You can download it directly from Powershell Gallery or GitHub and get it up and running in just a few moments.

I just saw this was a very old thread - but thought I would include it just in case it is helpful to others.


I am impressed by the doramaswow that this website provides best articles.If you would try this then you would also love it.


Reply