首页 > 解决方案 > 如何使用“reply_time_in_minutes”指标?

问题描述

我一直在尝试通过 Zendesk API 检索我的代理的回复时间数据。但是,每次我使用给定的指标“reply_time_in_minutes”时,我都会得到一个 KeyError。有人对我应该做什么有建议吗?

import requests
# Set the request parameters
url = 'https://domain.zendesk.com/api/v2/incremental/tickets.json? 
start_time=1563230494'
user = 'email' + '/token'
pwd = 'token'

# Do the HTTP get request
response = requests.get(url, auth=(user, pwd))

# Check for HTTP codes other than 200
if response.status_code != 200:
    print('Status:', response.status_code, 'Problem with the request. 
    Exiting.')
    exit()

# Decode the JSON response into a dictionary and use the data
data = response.json()

ticket_list1 = data['tickets']

for ticket1 in ticket_list1:
    print(ticket1['reply_time_in_minutes'])

标签: pythonzendesk-api

解决方案


“reply_time_in_minutes”是您正在使用的增量工单导出端点中不可用的工单指标。要获取有关指标的数据,您需要使用 ' sideload ' metric_sets

url = 'https://domain.zendesk.com/api/v2/incremental/tickets.json?
start_time=1563230494&include=metric_sets'

推荐阅读