James Maguire
James Maguire

Reputation: 570

Podio API - Python filter request

Running pypodio2

I am trying to build a simple script which pulls a set of filtered items with the item filter command. It is for my own personal use to automate invoice generation.

My end game is to filter by a calculated date field - i.e. the field pulls a date from relationship.

However so far can't seem to get my request to filter any values at all. The is a sample of what I would expect to pull all items in the app where the quantity-kg value is 10.

c.Item.filter(14928728,attributes={'filter_by':[{"quantity-kg":10}]})

This returns all the items in the app.

I have tried a few different things but can't seem to work this out.

So first I would like to work out the correct syntax for passing simple request, and then work out how to pass a request to filter by date.

Upvotes: 1

Views: 608

Answers (1)

James Maguire
James Maguire

Reputation: 570

Worked it out, my original code had some mistakes.

  1. 'filters' not 'filter_by'
  2. No need to pass a list as the attributes values
  3. Filter values need to be in 'from' 'to' from.

So the code is:

c.Item.filter(14928728,attributes={'limit':500,'filters':{'121293716':{'from':'2‌​016-08-09','to':'2016-08-09'}}}) 

for the dates, or

c.Item.filter(14928728,attributes={'limit':500,'filters':{'quantity-kg':{'from':‌​10,'to':20}}}) 

for the value field.

Upvotes: 7

Related Questions