Pageination body variable not in request?

Defined variable for pageination is not present in body of request.

The API I’m working with needs the requested page number in the body of the request. A working example is:

curl --location 'https://businessapi.mosyle.com/v1/devices' \
--header 'Content-Type: application/json' \
--header 'accessToken: Access_Token' \
--header 'Authorization: Bearer Bearer_Token' \
--data '{
    "operation": "list",
    "options": {
        "os": "macos",
        "page": 1,
        "specific_columns": [
            "device_name",
            "device_type",
            "serial_number",
            "os"
        ]
    }
}'

What is the error message (if any)?

Problem in node ‘Get Some‘

The returned response was identical 5x, so requests got stopped

If I limit to 2 pages, the workflow completes.

[
    {
        "status": "OK",
        "response": [
            {
                "devices": [
                    {
                        "total_disk": "494.0000000000",
                        "ActiveManagedUsers": "[]",
                        "asset_tag": null,
                        "available_disk": "195.0000000000",
                        "CurrentConsoleManagedUser": "wirkkala",
                        "date_last_beat": "1733714267",
                        "device_model": "MacBookAir10,1",
                        "device_name": "TerryW MBA PDX M1",
                        "device_type": "COMPUTER",
                        "ethernet_mac_address": "80:65:7c:e7:ca:3a",
                        "HostName": "terryw-mba-pdx-m1.local",
                        "last_lan_ip": "10.0.0.69",
                        "LocalHostName": "terryw-mba-pdx-m1",
                        "model_name": "MacBook Air",
                        "os": "mac",
                        "osversion": "15.1.1",
                        "serial_number": "FVFHQ0C3Q6LW",
                        "tags": "fv,econw,sso",
                        "enrollment_type": "GENERAL",
                        "cpu_model": "Apple M1",
                        "installed_memory": "16",
                        "device_model_name": "MacBook Air (M1, 2020)"
                    },
                    {
                        "total_disk": "494.0000000000",
                        "ActiveManagedUsers": "[]",
                        "asset_tag": null,
                        "available_disk": "251.0000000000",
                        "CurrentConsoleManagedUser": "sausedo",
                        "date_last_beat": "1733714705",
                        "device_model": "MacBookAir10,1",
                        "device_name": "KrynS MBA PDX M1",
                        "device_type": "COMPUTER",
                        "ethernet_mac_address": "1c:91:80:b8:45:0f",
                        "HostName": "kryns-mba-pdx-m1.local",
                        "last_lan_ip": "192.168.0.22",
                        "LocalHostName": "kryns-mba-pdx-m1",
                        "model_name": "MacBook Air",
                        "os": "mac",
                        "osversion": "15.1.1",
                        "serial_number": "FVFFJ40YQ6LR",
                        "tags": "fv,econw,sso",
                        "enrollment_type": "GENERAL",
                        "cpu_model": "Apple M1",
                        "installed_memory": "16",
                        "device_model_name": "MacBook Air (M1, 2020)"
                    }
                ],
                "rows": 89,
                "page_size": 50,
                "page": 1
            }
        ]
    },
    {
        "status": "OK",
        "response": [
            {
                "devices": [
                    {
                        "total_disk": "494.0000000000",
                        "ActiveManagedUsers": "[]",
                        "asset_tag": null,
                        "available_disk": "195.0000000000",
                        "CurrentConsoleManagedUser": "wirkkala",
                        "date_last_beat": "1733714267",
                        "device_model": "MacBookAir10,1",
                        "device_name": "TerryW MBA PDX M1",
                        "device_type": "COMPUTER",
                        "ethernet_mac_address": "80:65:7c:e7:ca:3a",
                        "HostName": "terryw-mba-pdx-m1.local",
                        "last_lan_ip": "10.0.0.69",
                        "LocalHostName": "terryw-mba-pdx-m1",
                        "model_name": "MacBook Air",
                        "os": "mac",
                        "osversion": "15.1.1",
                        "serial_number": "FVFHQ0C3Q6LW",
                        "tags": "fv,econw,sso",
                        "enrollment_type": "GENERAL",
                        "cpu_model": "Apple M1",
                        "installed_memory": "16",
                        "device_model_name": "MacBook Air (M1, 2020)"
                    },
                    {
                        "total_disk": "494.0000000000",
                        "ActiveManagedUsers": "[]",
                        "asset_tag": null,
                        "available_disk": "251.0000000000",
                        "CurrentConsoleManagedUser": "sausedo",
                        "date_last_beat": "1733714705",
                        "device_model": "MacBookAir10,1",
                        "device_name": "KrynS MBA PDX M1",
                        "device_type": "COMPUTER",
                        "ethernet_mac_address": "1c:91:80:b8:45:0f",
                        "HostName": "kryns-mba-pdx-m1.local",
                        "last_lan_ip": "192.168.0.22",
                        "LocalHostName": "kryns-mba-pdx-m1",
                        "model_name": "MacBook Air",
                        "os": "mac",
                        "osversion": "15.1.1",
                        "serial_number": "FVFFJ40YQ6LR",
                        "tags": "fv,econw,sso",
                        "enrollment_type": "GENERAL",
                        "cpu_model": "Apple M1",
                        "installed_memory": "16",
                        "device_model_name": "MacBook Air (M1, 2020)"
                    }
                ],
                "rows": 89,
                "page_size": 50,
                "page": 1
            }
        ]
    }
]

Please share your workflow

Share the output returned by the last node

See above.

Information on your n8n setup

  • n8n version: 1.70.3
  • Database (default: SQLite): PostgresQL 15
  • n8n EXECUTIONS_PROCESS setting (default: own, main): Default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker on Digital Ocean
  • Operating system: Ubuntu Linux 22.04 LTS

Additional info. Here is the request sent.

ChatGTP says the pageination routine in the http request node is not designed to include pageination parameters in the body of a request. If this is true, it seems to me the ‘body’ should not be an option for “Update a parameter with each request.”

I have not looked at the source, so I don’t know.

It recommends manual pageination.

Looking forward to your comments.

-Russ

Hey @russellkg , the problem is, the pagination does not work with nested properties. To implement what you are looking for you would have to utilize the old method engaging looping. For example,

That also mean you have as meny sets s there are pages and you might need to use some aggregations to get all the items ended up in a single set.

That’s kinda what I thought. Either that or what ChatGPT told me. :slight_smile:

There are a few things about the Mosyle API that leave something to be desired. Using a post for just about every kind of call is just one.

Anyhow, I have this in my flow. It took me a second to get it to work, but it seems to be working now.

Maybe I should write it up as an example for when pagination doesn’t work? Putting it here means it’s published, and I don’t want to pollute the “normal and recommended” method.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.