使用zapier CLI创建自定义zapier集成。我的API端点在技术上不是一个创建,但它使用POST方法,所以我在zapier的创建定义下创建它。我将输出字段设置为空,但它在我的空响应对象上中断。
outputFields: []
错误消息:
We had trouble sending your test through.
Unexpected end of JSON input
Hide details
Troubleshooting Errors | Contact Support
What happened (You are seeing this because you are an admin):
Starting POST request to https://api.fake.com/v2/demo-finance/live/csh-search
Received 202 code from https://api.fake.com/v2/demo-finance/live/csh-search after 596ms
Received content ""
Unexpected end of JSON input
一切都按预期工作,请求通过它只是不满意空字符串响应不是有效的JSON。有没有办法告诉zapier这是一个可接受的响应对象?
大卫来自Zapier平台团队。
如果您的API以这种方式工作,那很好,但您仍然需要从函数中返回一些json serializable。尝试这样的事情:
const performCreate = async (z, bundle) => {
const response = await z.request('https://api.fake.com/v2/demo-finance/live/csh-search')
if (response.statusCode === 202) {
return {}
}
// handle errors, other cases, whatever
// just make sure to return an object
}
作为旁注,仅仅因为请求使用POST请求并不意味着它需要是Create
;它应该是对操作最有意义的任何类型。如果它是一个搜索(就像假网址建议的那样),搜索可能就是一种方法。