IBM Cloud 代码引擎:如何在 ping 订阅中传递非 JSON 数据?
IBM Cloud Code Engine: How to pass non-JSON data in ping subscription?
我正在尝试将一些表单数据从 Code Engine ping subscription 传递到我的应用程序。在创建命令中,我尝试了不同的方法将数据作为 POST 请求的一部分进行传递,但是当触发 ping 事件时,它在运行时导致了错误的参数。
ibmcloud ce sub ping create -n tweety --destination twitterbot --path /tweet
--schedule '07 4,8,13,17 * * *' --data 'SECRET_KEY=SET_YOUR_SECRET'
ibmcloud ce sub ping create -n tweety --destination twitterbot --path /tweet
--schedule '07 4,8,13,17 * * *' --data '{"SECRET_KEY":"SET_YOUR_SECRET"}'
如何将数据作为常规文本数据而不是 JSON 传递?
我花了一段时间才弄明白。 The CLI command allows to pass --content-type
。在文档中是示例 application/json。对于常规数据,它将是表单数据和 urlencoded。以下作品,即使用 application/x-www-form-urlencoded:
ibmcloud ce sub ping create -n tweety --destination twitterbot --path /tweet
--schedule '07 4,8,13,17 * * *' --data 'SECRET_KEY=SET_YOUR_SECRET'
--content-type 'application/x-www-form-urlencoded'
CLI 现在支持非json:
ibmcloud ce sub ping create -n pinger --data "hello" -d myapp
正文会产生这样的结果:
你好
我正在尝试将一些表单数据从 Code Engine ping subscription 传递到我的应用程序。在创建命令中,我尝试了不同的方法将数据作为 POST 请求的一部分进行传递,但是当触发 ping 事件时,它在运行时导致了错误的参数。
ibmcloud ce sub ping create -n tweety --destination twitterbot --path /tweet
--schedule '07 4,8,13,17 * * *' --data 'SECRET_KEY=SET_YOUR_SECRET'
ibmcloud ce sub ping create -n tweety --destination twitterbot --path /tweet
--schedule '07 4,8,13,17 * * *' --data '{"SECRET_KEY":"SET_YOUR_SECRET"}'
如何将数据作为常规文本数据而不是 JSON 传递?
我花了一段时间才弄明白。 The CLI command allows to pass --content-type
。在文档中是示例 application/json。对于常规数据,它将是表单数据和 urlencoded。以下作品,即使用 application/x-www-form-urlencoded:
ibmcloud ce sub ping create -n tweety --destination twitterbot --path /tweet
--schedule '07 4,8,13,17 * * *' --data 'SECRET_KEY=SET_YOUR_SECRET'
--content-type 'application/x-www-form-urlencoded'
CLI 现在支持非json:
ibmcloud ce sub ping create -n pinger --data "hello" -d myapp
正文会产生这样的结果:
你好