简体   繁体   English

Podio API-Python过滤器请求

[英]Podio API - Python filter request

Running pypodio2 运行pypodio2

I am trying to build a simple script which pulls a set of filtered items with the item filter command. 我正在尝试构建一个简单的脚本,该脚本使用item filter命令提取一组过滤的项目。 It is for my own personal use to automate invoice generation. 这是我自己用于自动生成发票的个人用途。

My end game is to filter by a calculated date field - ie 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. 这是我希望在数量千克值为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. 因此,首先,我想确定传递简单请求的正确语法,然后确定如何传递请求以按日期过滤。

Worked it out, my original code had some mistakes. 算出来,我的原始代码有一些错误。

  1. 'filters' not 'filter_by' '过滤器'不是'filter_by'
  2. No need to pass a list as the attributes values 无需传递列表作为属性值
  3. Filter values need to be in 'from' 'to' from. 过滤器值必须位于“ 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. 用于值字段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM