Api returns empty list of device profiles (V3)

When I make a request to http://server address:8095/api/device-profiles it always returns an empty “result” list:

‘{“totalCount”:“2”,“result”:[]}’

I have 2 device profiles in my system, so the “totalCount” is correct.

I read the forum and found similar problems with other api (like get device list) and the solution was to provide a non-zero “limit” parameter. But that didn’t solve it.

I’m doing this from Python:

 global_api_key = "eyJ..."
    headers = {
        "Authorization": f"Bearer {global_api_key}",
        "Content-Type": "application/json",
        "limit": "2"
    }

    url = f"http://{g_chirpstack_server}/api/device-profiles"
    response = requests.get(url, headers=headers)

Any help would be appreciated. Thank you!

Michael

Did you try with “limit”:2 instead of “limit”:“2”?

I’m using gRPC, so I’m not sure, but I think the limit should be passed as url parameter, not in the header.

1 Like

Yes, you were right, all I had to do was pass limit=2 as a parameter, NOT in the header. It works now. Thanks!

Here is the updated code in case anyone else is interested:

def get_device_profiles():

    headers = {
        "Authorization": f"Bearer {global_api_key}",
        "Content-Type": "application/json",
    }

    url = f"http://{g_chirpstack_server}/api/device-profiles"
    
    params = {
        "limit": 2,
    }
    response = requests.get(url, headers=headers, params=params)

    if response.status_code == 200:
        return response.json()
    else:
        raise Exception(f"Failed to fetch device profiles. Status code: {response.status_code}")
1 Like

This topic was automatically closed after 90 days. New replies are no longer allowed.