Stanko
Stanko

Reputation: 4475

Getting all items of app with python library does not work

from pypodio2 import api

# Authenticate as App
podio_client = api.OAuthAppClient(
    client_id=PODIO_CLIENT_ID,
    client_secret=PODIO_CLIENT_SECRET,
    app_id=PODIO_APP_ID,
    app_token=PODIO_APP_TOKEN,    
)

# Set limit to 100
items = podio_client.Item.filter(app_id=PODIO_APP_ID, attributes={}, limit=100)

My app has a total of 251 items and I expect that the API would return 100 items but it only returns 20... How to fix this?

print(items['total'])

251

print(items['filtered'])

251

print(len(items['items'])

20

Update

I tried it with the requests library but still no success...

import requests
payload = {
  "filters":{},
  "limit": 30
}
resp = requests.post(url="https://api.podio.com/item/app/randomappid/filter/", 
                    headers={'authorization': 'OAuth2 randomn0mber'},
                    data=payload)

len(resp.json()['items'])

20

API call docs: https://developers.podio.com/doc/items/filter-items-4496747

Upvotes: 3

Views: 386

Answers (2)

limit must pass thru the attributes parameter.

# Set limit to 100
items = podio_client.Item.filter(app_id=PODIO_APP_ID, attributes={"limit": 100})

Upvotes: 5

Stanko
Stanko

Reputation: 4475

Not ideal but using the deprecated api call I get the desired results... Would still like to know how to do it using the filter api call.

params = {"limit": 300}
resp = requests.get(url="https://api.podio.com/item/app/randomappid/", 
                    headers={'authorization': 'OAuth2 randomn0mber'},
                    params=params)

len(resp.json()['items'])

251

Upvotes: 0

Related Questions