在 Zendesk 中使用 Zapier 获取评论

问题描述

我希望在 Zapier 中添加一个步骤,其中仅查找票的评论

Zendesk 文档显示了以下 curl,这在 Postman 中完美运行并返回指定票证的所有评论

“Code by Zapier”功能需要我输入 javascript 或 python。

我对两者都不太了解,使用转换为 Python 的 Curl,我得到 output_missing 请定义输出或尽早返回。

enter image description here

我想检索 JSON 中的所有内容,其中“type”:“Comment”,“public”:false,

curl https://{subdomain}.zendesk.com/api/v2/tickets/{ticket_id}/comments.json \
  -H "Content-Type: application/json" -v -u {email_address}:{password}

如果有人能指出我正确的方向,我将不胜感激。

代码如下:

import requests 
import json 

url = "domain.zendesk.com/api/v2/tickets/1234/comments.json" 
payload={} 
headers = { 
    'Content-Type': 'application/json','Authorization': 'Basic xxx' 
} 
response = requests.request("GET",url,headers=headers,data=payload) 
print(response.text)

解决方法

您会在 the docs 中注意到响应必须从代码中返回,而不仅仅是打印:

# ... your exist code

return response.json()

作为使用 Code by Zapier 的替代方法,您可以尝试使用 Webhooks by Zapier,这样您就可以轻松地向 Zendesk 发出这个单一请求。如果您查看“发出请求”操作。这里有详细说明:https://zapier.com/help/create/code-webhooks/send-webhooks-in-zaps#add-a-webhook-action

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...