我在Zapier中有一个GET请求,使用该API从预定系统mindbody获取瑜伽课程列表; https://developers.mindbodyonline.com/PublicDocumentation/V6#get-classes
Zapier确实具有自动获取“所有”结果的功能,即使最大限制为200,Zap也需要获取下一页结果。默认情况下,我可以得到200个结果的限制,偏移量为0。
我需要Zapier来获得前200个,将偏移量增加200个,将结果获得200-400,依此类推。最终结果可能是将650个结果全部合并到Zap中,然后我可以将其用于其他任务(计数,求和,查找等)
如何使用Zapier Code任务使用以下参数以增量方式循环/获取JSON列表中的所有项目:
在响应正文中返回的示例分页信息:
https://developers.mindbodyonline.com/PublicDocumentation/V6#pagination
{ “ PaginationResponse”:{ “ RequestedLimit”:10, “ RequestedOffset”:20, “ PageSize”:10, “总结果”:128 }, “类别”:[ 。 。 。 ] }
今天在Zapier中采样GET和响应;
样品数据输入(获取请求)
json_key:访问 未展平:是 标头: 内容类型:application / json SiteId:xxx API密钥:xxx 名称:xxx 网址:https://api.mindbodyonline.com/public/v6/client/clientvisits 数据: 限制:200 开始日期:2015-01-01T00:00:00 结束日期:2099-01-01T00:00:00 客户编号:xxx 偏移:0 As_json:否
返回了样品数据
访问: 1: 类别编号:xxx LastModifiedDateTime:0001-01-01T00:00:00Z 化妆:假 约会编号:0 服务名称: 约会性别偏好:无 截止日期时间:2019-12-11T08:15:00 客户编号:xxx LateCancelled:false 动作:无 服务编号: SiteId:xxx 登录:true 开始日期时间:2019-12-11T07:15:00 员工编号:x LocationId:x WebSignup:假 产品编号: 约会状态:无 ID:xxx 名称:xxx 2: 类别编号:xxx LastModifiedDateTime:0001-01-01T00:00:00Z 化妆:假 约会编号:0 服务名称: 约会性别偏好:无 结束日期时间:2019-12-11T09:30:00 客户编号:xxx LateCancelled:false 动作:无 服务编号: SiteId:xxx 登录:true 开始日期时间:2019-12-11T08:30:00 员工编号:xxx LocationId:xx WebSignup:假 产品编号: 约会状态:无 ID:xxx 名称:xxx
分页响应: 总结果:2 页面大小:2 RequestedOffset:0 RequestedLimit:
更新12/19/2019: 1)呼叫端点; https://api.mindbodyonline.com/public/v6/client/clientvisits带有查询参数; 开始日期:2015-01-01T00:00:00 截止日期:2099-01-01T00:00:00 偏移量:0 客户编号:XXX 上限:200 标头; 名称:xxx SiteId:xxx api键:xxx 内容类型:application / json
邮递员中的样本回复: { “ PaginationResponse”:{ “ RequestedLimit”:200, “ RequestedOffset”:0, “ PageSize”:2 “总计结果”:2 }, “访问”:[ { “ AppointmentId”:0, “ AppointmentGenderPreference”:“无”, “ AppointmentStatus”:“无”, “ ClassId”:xxx, “ ClientId”:“ xxx”, “ StartDateTime”:“ 2019-04-27T09:45:00”, “ EndDateTime”:“ 2019-04-27T10:45:00”, “ Id”:xxx, “ LastModifiedDateTime”:“ 0001-01-01T00:00:00Z”, “ LateCancelled”:否, “ LocationId”:1 “彩妆”:假, “ Name”:“ Yoga Barre”, “ ServiceId”:null, “ SignedIn”:是的, “ StaffId”:xxx, “ WebSignup”:否, “动作”:“无” }, { “ AppointmentId”:0, “ AppointmentGenderPreference”:“无”, “ AppointmentStatus”:“无”, “ ClassId”:xxx, “ ClientId”:“ xxx”, “ StartDateTime”:“ 2019-07-19T16:45:00”, “ EndDateTime”:“ 2019-07-19T17:45:00”, “ Id”:273726, “ LastModifiedDateTime”:“ 0001-01-01T00:00:00Z”, “ LateCancelled”:否, “ LocationId”:1 “彩妆”:假, “名称”:“冥想”, “ ServiceId”:null, “ SignedIn”:是的, “ StaffId”:xxx, “ WebSignup”:否, “动作”:“无” } ] }
如果TotalResults = 201或更大,则应将请求的偏移量设置为200并再次循环,依此类推。我在响应中唯一需要的数据是“ SignedIn”,如果将所有ClientVisits收集在一起,则可以在以后的步骤中进行zapier计数或求和。希望有道理!