无法使用Nifi curl命令启动处理器

时间:2019-04-26 07:44:47

标签: shell curl apache-nifi

我正在尝试运行以下curl命令以在Nifi中启动和停止处理器:

curl -i -H 'Content-Type: application/json' -XPUT -d '{"id":"016a1048-82dc-1262-fc26-ffcac4e76c1a","status":"Running"}' http://localhost:9090/nifi-api/processors/016a1048-82dc-1262-fc26-ffcac4e76c1a

但是我收到以下错误:

HTTP/1.1 400 Bad Request
Date: Fri, 26 Apr 2019 07:41:09 GMT
X-Frame-Options: SAMEORIGIN
Content-Security-Policy: frame-ancestors 'self'
X-XSS-Protection: 1; mode=block
Content-Type: text/plain
Vary: Accept-Encoding
Content-Length: 423
Server: Jetty(9.4.11.v20180605)

Cannot construct instance of `org.apache.nifi.web.api.dto.status.ProcessorStatusDTO` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('Running')
 at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 55] (through reference chain: org.apache.nifi.web.api.entity.ProcessorEntity["status"])

我在做什么错了?

1 个答案:

答案 0 :(得分:1)

请参阅api文档:https://nifi.apache.org/docs/nifi-docs/rest-api/index.html

您需要致电PUT /processors/{id}/run-status

身体应该是这样的:

{
    "revision": {
        "clientId": "value",
        "version": 0,
        "lastModifier": "value"
    },
    "state": "value",
    "disconnectedNodeAcknowledged": true
}

您还可以在浏览器开发工具中看到正确的请求