问题描述
我希望在 Zapier 中添加一个步骤,其中仅查找票的评论。
Zendesk 文档显示了以下 curl,这在 Postman 中完美运行并返回指定票证的所有评论。
“Code by Zapier”功能需要我输入 javascript 或 python。
我对两者都不太了解,使用转换为 Python 的 Curl,我得到 output_missing 请定义输出或尽早返回。
我想检索 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