cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Maxl
Engaged Sweeper

Hey everyone,

sorry if I am asking an obvious question.

I've been playing around with the LS cloud API but I cannot get custom fields from it no matter what I try.

I get responses just fine when querying for the below informations.

query getAssetResources {
  site(id"xxx") {
    assetResources(
      assetPagination{ limit100, pageFIRST }
      fields[
        "assetBasicInfo.name"
        "assetCustom.model"
      ]
      filters{
          conjunctionAND
          conditions[
              {operatorLIKE, path"assetBasicInfo.name", value"xxx"}
          ]
      }
    ) {
      total
      pagination {
        limit
        current
        next
        page
      }
      items
    }
  }
}


However, as soon as I add assetcustom.fields to the fields, I get an error.

query getAssetResources {
  site(id"xxx") {
    assetResources(
      assetPagination{ limit100, pageFIRST }
      fields[
        "assetBasicInfo.name"
        "assetCustom.model"
        "assetCustom.fields"
      ]
      filters{
          conjunctionAND
          conditions[
              {operatorLIKE, path"assetBasicInfo.name", value"xxx"}
          ]
      }
    ) {
      total
      pagination {
        limit
        current
        next
        page
      }
      items
    }
  }
}

{
    "errors": [
        {
            "message": "Invalid path: assetCustom.fields"
        }
    ],
    "data": {
        "site": {
            "assetResources": null
        }
    }
}

Thanks in advance for any help.

Best Regards,
Matthias
4 REPLIES 4
DiegoPacini
Product Team
Product Team

Hi Maxl, 

custom fields are actually available in the public API, as you can read here:

https://docs.lansweeper.com/docs/api/types#assetcustom

The correct path to those are:
assetCustom.fields.value
assetCustom.fields.fieldKey 
assetCustom.fields.name

I hope this helps

 

StillGoing
Engaged Sweeper III

I was just going to post a question on this topic when I found your post. I'm hoping I'm wrong, but from what I can see at this point, custom fields in Lansweeper Cloud can only be used for defining custom views. They are not available to use for reporting, nor are they available via the API.

I'm hoping I'm wrong and someone can correct me. I find Lansweeper's direction regarding custom data (or lack thereof) to be very frustrating so far.

Hey,

I was playing around some more with it. Turns out as of right now you can only filter a few set of fields with the API.

When you try to filter a field that was not meant to be queried, you get this response.

There is an invalid path for filter. Path values can only be: key, installationId, assetBasicInfo.type, assetBasicInfo.name, assetBasicInfo.domain, assetBasicInfo.ipAddress, assetBasicInfo.mac, assetBasicInfo.description, assetBasicInfo.userName, assetCustom.stateName, assetCustom.dnsName, assetCustom.stateName, assetCustom.serialNumber, assetCustom.manufacturer, assetCustom.model, installKey, assetCustom.purchaseDate, assetCustom.warrantyDate, assetBasicInfo.firstSeen, assetBasicInfo.lastSeen

So yeah. As of right now the API is useless IMO. Why care creating an API when I can't query for every single field?

Regards,
Matthias

Hi Maxl, it's true that custom fields are not filterable properties in the API. Thanks for the input, we'll work on that!
Please keep an eye on the Release Notes section to see updates!
https://docs.lansweeper.com/docs/release-notes/