【问题标题】:How do I use the "reply_time_in_minutes" metric?如何使用“reply_time_in_minutes”指标?
【发布时间】:2019-07-30 00:03:28
【问题描述】:

我一直在尝试通过 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'])

【问题讨论】:

  • a 404 problem 是什么意思?您只是尝试访问字典中的值,而不是发出 http 请求。发布带有完整回溯的错误消息(如果有)。
  • 如果说 404 问题时出现 404 错误,则某些内容不可用,因为未找到 404。因此,您的网址可能有问题,或者用户不存在或类似情况。但是更多我们需要一个准确的错误信息
  • 对不起,我写错了404问题。这是我在 print(ticket1['reply_time_in_minutes']) KeyError: ' reply_time_in_minutes'"

标签: python zendesk-api


【解决方案1】:

'reply_time_in_minutes' 是您正在使用的not available in the incremental ticket export endpoint 工单指标。要获取有关指标的数据,您需要“sideloadmetric_sets using

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-04-04
    • 2023-03-28
    • 2021-07-16
    • 1970-01-01
    • 2020-09-14
    • 2020-03-31
    • 2018-02-07
    • 2020-06-15
    相关资源
    最近更新 更多