ZIS包:使用jq创建HTTP请求体
下面的ZIS包包含一个变换行动。Transform操作使用金桥创建一个JSON对象。对象使用参考路径作为属性键。在Transform操作之后,对象被传递到HTTP请求的请求体ZIS自定义动作.
bundle的Transform动作被高亮显示。当测试bundle时,将“EXTERNAL_TARGET_URL”替换为RequestBin端点URL。将“INTEGRATION”替换为您的集成键。
{
“名称”:“示例集成”,
“描述”:"使用参数作为键的HTTP请求正文",
“zis_template_version”:“2019-10-14”,
“亚博电脑端资源”:{
“postToExternalTarget”:{
“类型”:“子::行动::Http”,
“属性”:{
“名称”:“postToExternalTarget”,
“定义”:{
“方法”:“职位”,
“url”:“EXTERNAL_TARGET_URL”,
“requestBody美元。”:“.requestBody美元”
}
}
},
“NewUserFlow”:{
“类型”:“子:流”,
“属性”:{
“名称”:“NewUserFlow”,
“定义”:{
“StartAt”:“mockGetCustomField”,
“州”:{
“mockGetCustomField”:{
“类型”:“通过”,
“结果”:{
“custom_field_key”:“favorite_product”,
“custom_field_value”:“Canyonero”
},
“ResultPath”:“.custom_field美元”,
“下一个”:“transformCustomFieldObj”
},
“transformCustomFieldObj”:{
“类型”:“行动”,
“ActionName”:“子:常见的变换:金桥”,
“参数”:{
“数据。美元”:“.custom_field美元”,
“expr”:"{(.custom_field_key): .custom_field_value}"
},
“ResultPath”:“.custom_request_body美元”,
“下一个”:“makeHttpRequest”
},
“makeHttpRequest”:{
“类型”:“行动”,
“ActionName”:“子:集成:行动:postToExternalTarget”,
“参数”:{
“requestBody美元。”:“.custom_request_body美元”
},
“结束”:真正的
}
}
}
}
},
“NewUserSpec”:{
“类型”:“子::JobSpec”,
“属性”:{
“名称”:“NewUserSpec”,
“event_source”:“支持”,
“event_type”:“用户。UserCreated”,
“flow_name”:“子:集成:流:NewUserFlow”
}
}
}
}
bundle的Transform动作从通过国家:
{
“custom_field_key”:“favorite_product”,
“custom_field_value”:“Canyonero”
}
在应用jq表达式之后,Transform动作输出以下对象:
{
“favorite_product”:“Canyonero”
}
对象然后被传递给requestBodyZIS自定义操作的选项。