REST API v3: Filtering assets from JSON input.

REST API v3: Filtering assets from JSON input.

I am attempting to use the REST API v3 via Powershell to get a list of all assets in Service Desk. However, I would like to pre-filter this list, since we have well over 2,000 assets listed, most of which are not relevant to my needs. I would like to filter by a specific product name.

Here is how I am currently fetching:


  1. [int]$index = "1"
  2. while (!$check) {
  3. $input = @"
  4. {
  5.     "list_info": {
  6.         "row_count": 100,
  7.         "start_index": $index,
  8.         "sort_field": "name",
  9.         "sort_order": "desc",
  10.         "get_total_count": true,
  11.         }
  12.     }
  13. }
  14. "@

  15. $header = @{TECHNICIAN_KEY=$ApiKey} 
  16. $params = @{input_data=$input;format='json'}
  17. $Uri = $SdpUri + "/api/v3/assets"
  18. $result = Invoke-RestMethod -Method GET -Uri $Uri -Headers $header -Body $params -ContentType "application/x-www-form-urlencoded" 
  19. if ($result) {
  20. $result.assets | Select-Object name,@{n="Product";e={$_.product.name}},@{n="User";e={$_.user.name}} | Where-Object {$_.product -like "*7070*"}
  21. $index = $index+100
  22. }
  23. Else {
  24.     $check = $true
  25.     Write-Host "Ending run"
  26.     break
  27. }
  28. }

This relies on post-processing the data to get what I want, which is extremely time consuming and resource intensive.

is there a way that I can add an option to to the JSON input pre-filter to get only the computer assets that I want based on model? The property name on the Powershell output is Product.Name.



                  New to ADSelfService Plus?