我猜您查询中的问题是:
created%3E2017-12-14T00:00:00Z%20created%3C2017-12-15T00:00:00Z
您似乎从 12 月 14 日午夜查询到 12 月 15 日午夜,所以结果集应该只返回 12 月 14 日的票。
我查看了Zendesk API Search 文档,我会说它应该足以编码:
created>2017-12-14T00:00:00Z created<2017-12-16T00:00:00Z
反而:
created%3E2017-12-14T00:00:00Z%20created%3C2017-12-16T00:00:00Z
您可以找到一些特定的python 示例和这个分页文档。您的代码应如下所示:
from urllib.parse import urlencode
import requests
results = [] # Empty list store paginated results
credentials = 'your_zendesk_email', 'your_zendesk_password'
session = requests.Session()
session.auth = credentials
params = {
'query': 'type:ticket created>2017-12-14T00:00:00Z created<2017-12-16T00:00:00Z',
'sort_by': 'created_at',
'sort_order': 'desc'
}
url = 'https://your_subdomain.zendesk.com/api/v2/search.json?' + urlencode(params)
while url:
response = session.get(url)
data = response.json()
results += data['results']
url = data['next_page'] # At the last page, the API should return false
print json.dumps(results.json(), sort_keys=True, indent=10)