首页 > 解决方案 > 使用 ExecuteProcess 和 --data-binary 标记的 Curl 函数在 Apache Nifi 中不起作用

问题描述

我在将 ExecuteProcess 与使用--data-binary标签的 curl 命令一起使用时遇到问题。当我在终端中运行此命令时,它可以工作:

curl https://api.webflow.com/collections/5f7146cacb2fc106ad4c0386/items/ \
-H "Authorization: Bearer bce8078f0495fc47a5e9d2534f25e1335d0aa316601c2fc9971b169f1aeadc17" \
-H "accept-version: 1.0.0" \
-H "Content-Type: application/json" \
--data-binary $'{
"fields": {
"name": "Exciting blog post title",
"slug": "exciting-post",
"_archived": false,
"_draft": false

}
}'

但是,当我在 NiFi 中将其作为 ExeccuteProcess 运行时,它会返回以下错误:

{
  "msg": "Invalid request body",
  "code": 400,
  "name": "ValidationError",
  "path": "/collections/5f7146cacb2fc106ad4c0386/items",
  "err": "ValidationError: Invalid request body"
}

这是指向 createItem curl 命令的 WebFlow 文档的链接:  https ://developers.webflow.com/#create-new-collection-item

有人可以给我的任何帮助都会很棒。如果我应该使用另一个处理器来发出这些类型的请求,那就太棒了。

标签: curlapache-nifiexecuteprocesstask

解决方案


这里的简单解决方案是将其包装在 shell 脚本(或 Windows 上的 PowerShell/BAT 文件)中并调用该脚本。


推荐阅读