从get webhook响应嵌套json创建数组

问题描述

我设置的当前Zapier步骤创建了一个对外部服务的GET请求。该服务将回复嵌套的数据列表。我需要做的最后一步是向另一个API发出多个PUT请求,其中URL的一部分是GET响应中的值。没有固定数量的ID /时间,需要将其放入。

当前,如果我仅使用GET进行操作,则下一步是PUT,它将我需要放入的所有ID值(以逗号分隔的列表)放在API网址的末尾。我需要他们为每个ID分别提出PUT请求。

任何帮助将不胜感激。

This shows the response to the GET request (Images shows only the first part. There will are more in the response)

This is the PUT request. It currently puts them as a comma separated list. which causes an error. each of the values needs to process as a separate PUT.

解决方法

您可能要考虑编写自己的code step,以将嵌套的数据格式化为对象数组(JSON)。然后,您可以将数据返回到output并实现所需的效果,在下一步中,output数组中的每个项目都会执行PUT请求。

以下是Zapier关于此策略的说明:

Setting the output to an array of objects will run the subsequent steps multiple times — once for each object in the array. If Code by Zapier is the Zap's trigger and an empty array is returned,nothing happens. You can think of it like a polling trigger that did not get any results in the HTTP response. This functionality is exclusive to triggers — returning an empty array in a Code by Zapier action does not have the same effect.