How to add an existing asset to an existing ticket with the API?

Pretty much what the title says. I’ve managed to do some pretty cool stuff with the API and PowerShell scripts running on a schedule. Unfortunately, this isn’t something I’ve been able to do.

If someone could provide an example of a JSON File containing the body on how an asset is added, that would be great. So far, this is what I have:

$APIKey = 'MyApiKey'
$EncodedCredentials = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(('{0}:{1}' -f $APIKey, $null)))
$Header = @{}
$Header.Add('Authorization', ('Basic {0}' -f $EncodedCredentials))

$parameters = @{
            assets = @{
                display_id = "8232"

$Parameters = ConvertTo-Json $parameters

invoke-RestMethod -URI '' -Headers $Header -ContentType "application/json" -Method PUT -Body $Parameters

For clarity, that would make the JSON contents:

    "assets":  {
                   "display_id":  "8232"

Hi @Abe_Summers ,

Here is the list of things available.

  1. Adding asset type
  2. Asset addition API
  3. For adding assets to a ticket use the PUT API

For creating an asset type

curl --location 'https://<domain>' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic <API_KEY>' \
--data '{"name": "Chromebook", "parent_asset_type_id": 8, "description":"Asset type for all chromebooks"}'

For creating the asset The cURL would be as follows

curl --location 'https://<domain>' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic <API_KEY>' \
--data '{
    "name": "Macbook Pro",
    "asset_type_id": 25,
    "asset_tag": "ASSET-9",
    "impact": "low",
    "usage_type": "permanent",
    "description": "13.3-inch (diagonal) LED-backlit glossy widescreen display,1440-by-900 resolution",
    "location_id": null,
    "agent_id": null,
    "department_id": null,
    "group_id": 9,
    "assigned_on": "2014-07-26T12:25:04+05:30",
    "type_fields": {
        "product_25": 10,
        "vendor_25": 14,
        "cost_25": 5000,
        "salvage": 100,
        "depreciation_id": 30,
        "warranty_25": 20,
        "acquisition_date_25": "2018-07-26T12:25:04+05:30",
        "warranty_expiry_date_25": "2018-07-26T12:25:04+05:30",
        "domain_25": 1,
        "asset_state_25": "In Use",
        "serial_number_25": "SW12131133",
        "last_audit_date_25": "2014-07-26T12:25:04+05:30"

For adding an asset to an existing ticket

curl --location --request PUT 'https://<domain>' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic <API_KEY>' \
--data-raw '{ "description": "Update ticket with assets", "status": 2, "email": "", "priority": 1, "subject": "Update ticket with assets", "assets": [ { "display_id": 7 }, { "display_id": 8 }]}'

I hope this helps.


Hi Thakur,

Apologies for the delay, any chance you know how to do this in PowerShell?