python - 如何使用“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'])
解决方案
“reply_time_in_minutes”是您正在使用的增量工单导出端点中不可用的工单指标。要获取有关指标的数据,您需要使用 ' sideload ' metric_sets
url = 'https://domain.zendesk.com/api/v2/incremental/tickets.json? start_time=1563230494&include=metric_sets'
推荐阅读
- javascript - 将一组元素属性加载为数组数组
- amazon-web-services - AWS SQS 中缺少 s3 事件
- google-apps-script - 如何使用谷歌电子表格中的独特项目作为谷歌表单列表项目的选择?
- java - 为什么文本显示在一行?
- c++ - 使析构函数不是虚拟的,在特殊情况下删除基指针是否安全?
- c# - AssemblyLoadContext 未正确卸载
- php - php 不打印出 _POST 方法
- docker - eXo 平台 - 插件管理不下载目录
- c# - 尝试安装 Windows 服务应用程序时出现错误 1067
- javascript - 在其他函数中作为参数传递的函数被乘法触发