Community FAQ
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
MrNico
Engaged Sweeper III

Hello, I've been slowly advancing in my testing using the lansweeper API. Now I have the following problem, I understand that it is possible to make a "pagination" of the results, my doubt is how I "advance" between one page and another. Can you help me.. Thank you

If that's my query, what should the next query look like to bring in the other items?

 

 

query getAssetResources {
  site(id: "xxxxxxxxxxxxxxxxxxxxx") {
    assetResources(
        assetPagination: { limit: 2, page: FIRST }
      fields: [
        "assetBasicInfo.name"
        "assetBasicInfo.userDomain"
        "assetBasicInfo.description"
        "operatingSystem.name"
      ]
    ) {
      total
      items
    }
  }
}

 

Spoiler
 

 

3 REPLIES 3
MrNico
Engaged Sweeper III

 

Thanks for the response, here I have my example of the query that does work and returns information, but I don't know what the next query should be like to bring the following results.

I think they complicated something that should be simpler.  🤔

 

query getAssetResources {
  site(id: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx") {
    assetResources(
      fields: [
        "assetBasicInfo.name"
        "assetBasicInfo.userDomain"
        "assetBasicInfo.description"
        "assetBasicInfo.type"
      ]
         filters: {
        conjunction: AND
        conditions: [
          { operator: EQUAL, path: "assetBasicInfo.type", value: "Windows" }
        ]
      }
    ) {
      total
          pagination {
        limit
        current
        next
        page
      }
      items
    }
  }
}

The answer is...

{
    "data": {
        "site": {
            "assetResources": {
                "total": 690,
                "pagination": {
                    "limit": 500,
                    "current": "MzU0MC1Bc3NldC03NTA2Zjc3NS0xMWIyLTQ3NGItOTVhOC00MzZjZTU0MmRhOGI=",
                    "next": "MzzzMS1Bc3NldC03NTA2Zjc3NS0xMWIyLTQ3NGItOTVhOC00MzZjZTU0MmRhOGI=",
                    "page": "FIRST"
                },
                "items": [
                    {
                        "assetBasicInfo": {
                            "userDomain": "xxxxxxx",
                            "name": "Ssssssssssssssssssss",
                            "type": "Windows",
                            "description": "Ssssssssssssssss"
                        },
                        "key": "MTU0MC1Bc3NldC03NTA2Zjc3NS0xMWIyLTQ3NGItOTVhOC00dddjZTU0MmRhOGI="
                    },
 ...................
...................

Could you explain to me what the next query should be like to bring the following data?

 

Thank you

 

 

EthanBills
Lansweeper Employee
Lansweeper Employee

Hi,

The next query you should use given the following response should be:

query getAssetResources {
  site(id: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx") {
    assetResources(
      assetPagination: { cursor: "MzzzMS1Bc3NldC03NTA2Zjc3NS0xMWIyLTQ3NGItOTVhOC00MzZjZTU0MmRhOGI=" limit: 500, page: NEXT }
      fields: [
        "assetBasicInfo.name"
        "assetBasicInfo.userDomain"
        "assetBasicInfo.description"
        "assetBasicInfo.type"
      ]
         filters: {
        conjunction: AND
        conditions: [
          { operator: EQUAL, path: "assetBasicInfo.type", value: "Windows" }
        ]
      }
    ) {
      total
          pagination {
        limit
        current
        next
        page
      }
      items
    }
  }
}

This will give you the next set of assets that were not returned with the initial results of the query.

Thanks!

EthanBills
Lansweeper Employee
Lansweeper Employee

Hello,

When you run a query that contains pagination, the pagination should be returned at the top of the query. The response will contain the limit of assets, your cursor's "current" position, and the cursor's "next" position. The current position refers to the beginning of the page, and the next to the end of the page of assets. The "next" cursor is important to page through your assets. Once you run an initial query and have the next cursor information you should construct your next pagination like so: assetPagination: { cursor: "xxxxxx-yyyyyy-zzzz-aaaaa99-bbbbbb" limit: 10, page: NEXT } by adding in the cursor string that is returned in the "next" field of your previous query. This will allow you to page through your assets until you reach the end and no assets are returned. It is important to always specify "NEXT" as if you type "FIRST" it will always give you the first page regardless of the cursor you select. For more information regarding pagination please view: Make your first requests | Documentation – Lansweeper. Finally, I would suggest increasing your limit of assets from 2 if you have a large number of assets as it will take a very long time to page through only 2 at a time.

Thanks!

General Discussions

Find answers to technical questions about Lansweeper.

New to Lansweeper?

Try Lansweeper For Free

Experience Lansweeper with your own data.
Sign up now for a 14-day free trial.

Try Now