Created on 08-03-2016 01:51 PM - edited 08-18-2019 04:35 AM
I have created a simple data flow(above) using the NIFI GUI but I need to execute the same via the NIFI REST API.I am trying to execute the processor "GetFileTask" using the command below:
curl -i -X PUT -H 'Content-Type: application/json' -d '{"revision":{"clientId":"b7aff2f1-fb0e-4abd-90f4-c64d68989a5b"},"processors":{"id":"9dbceb31-9715-40b7-83c4-118cb5bf7a64","running":"true"}}'
http://localhost/nifi-api/controller/processors/b5a9293b-b9bd-4258-b9fb-93607843a327
I am a bit confused about how to generate the URL we are using in the command above i.e
http://localhost/nifi-api/controller/processors/b5a9293b-b9bd-4258-b9fb-93607843a327
Is it a web service?When I create the job in GUI is it already created or do I need to create it separately? Please provide some inputs on how to frame this URL ?When I am trying to access the URL it is showing "Resource not Found".
Created 08-03-2016 02:14 PM
One would need to traverse from the root group and down to your processor to find it (or use Search api to get the processor ref). In any case, some additional logic in your script if you wanted to avoid hardcoding the processor uuid.
On another note, what are you trying to achieve? Can you do it by using built-in cron scheduling in processors? NiFi flows are generally designed to always run, not turned on and off like a workflow with dependencies.
Created 08-03-2016 04:18 PM
I am starting from the controller and then going to the processor since there are no process groups but this URL is throwing error as mentioned above.Could you please site an example because I am following the step you mentioned.Is there anything wrong with this URL?
Created 08-04-2016 01:53 AM
The URL is below:
curl -i -X PUT -H 'Content-Type: application/json' -d '{"revision":{"version":??,"clientId":"test"},"processor":{"id":"20eb7bbd-2f68-4538-aa13-0f4fa33e63c4","state":"RUNNING"}}' http://localhost:9090/nifi-api/controller/process-groups/root/processors/20eb7bbd-2f68-4538-aa13-0f4...
Since your processor is not in a processor group you use "root" in the URL as the proccess-group-id, you still need to follow the pattern: /controller/process-groups/{process-group-id}/processors/{id}
You will also need to specify a version (which I have in ??) This is NiFi's way of handling optimistic locking. To find the version you can use:
curl -i -X GET http://localhost:9090/nifi-api/controller/revision
Change the NiFi port accordingly.
Created 11-29-2016 09:19 AM
I am having the same issue, can you pls suggest if something is wrong. Thanks.
[root@node2 ~]# curl -i -X PUT -H 'Content-Type: application/json' -d '{"revision":{"version":1,"clientId":"test"},"processor":{"id":"8bb725ef-0158-1000-3f09-23bdf4b50c6e","state":"RUNNING"}}' http://localhost:8080/nifi-api/processors/8bb725ef-0158-1000-3f09-23bdf4b50c6e
HTTP/1.1 400 Bad Request
Date: Tue, 29 Nov 2016 09:17:50 GMT
Content-Type: text/plain
Transfer-Encoding: chunked
Server: Jetty(9.3.9.v20160517)
Message body is malformed. Unable to map into expected format.
Created 12-21-2016 11:57 AM
Created 08-08-2016 06:13 AM
Thanks for your inputs. It is working fine by using the
"root" as the processor group. and using the version properly.