Skip to main content
daniel_amalan
Silver ⭐️⭐️⭐️
Jun 18, 2018 10:19 PM UTC
Solved

How to Stop a Specific Apache NiFi Processor Using the NiFi REST API

We're looking to automate the shutdown/restart the processor instead of manually stopping through Nifi UI. We don't want to bring down everything through nifi.sh stop, instead looking to bring down a specific processor.

MattWho
MattWhoAnswer
Titanium ⭐️⭐️
Jun 18, 2018 10:47 PM UTC

@Dan Alan

-

Anything you can do via the UI, you should be able to accomplish using NiFi's rest-api.

https://nifi.apache.org/docs/nifi-docs/rest-api/index.html

-

The easiest way to learn what specific rest-api call you need to make to accomplish a task is through using the developer tools in your browser. Perform the action via the UI and then via developer tolls save off that action as a curl command.

-

for example (assume secured NiFi using a login provider):

obtain authentication token:

token=$(curl -k 'https://<nifi-node>:9091/nifi-api/access/token' --data 'username=<username>&password=<password>’)

-

Then use that token to stop a specific processor by processor UUID:

curl 'https://<nifi-node>:9091/nifi-api/processors/aab961c3-6bcd-18e7-0000-00001d74d4ea' -X PUT -H "Authorization: Bearer $token" -H 'Content-Type: application/json' -H 'Accept: application/json, text/javascript, */*; q=0.01' --data-binary '{"revision":{"clientId":"248a328f-a133-1cd0-18c1-8997e36ef898","version":1},"component":{"id":"aab961c3-6bcd-18e7-0000-00001d74d4ea","state":"STOPPED"}}' --compressed --insecure

-

Thank you,

Matt

-

When an "Answer" addresses/solves your question, please select "Accept" beneath that answer. This encourages user participation in this forum.

8 replies

MattWho
Titanium ⭐️⭐️
MattWhoAnswer
Titanium ⭐️⭐️
Jun 18, 2018 10:47 PM UTC

@Dan Alan

-

Anything you can do via the UI, you should be able to accomplish using NiFi's rest-api.

https://nifi.apache.org/docs/nifi-docs/rest-api/index.html

-

The easiest way to learn what specific rest-api call you need to make to accomplish a task is through using the developer tools in your browser. Perform the action via the UI and then via developer tolls save off that action as a curl command.

-

for example (assume secured NiFi using a login provider):

obtain authentication token:

token=$(curl -k 'https://<nifi-node>:9091/nifi-api/access/token' --data 'username=<username>&password=<password>’)

-

Then use that token to stop a specific processor by processor UUID:

curl 'https://<nifi-node>:9091/nifi-api/processors/aab961c3-6bcd-18e7-0000-00001d74d4ea' -X PUT -H "Authorization: Bearer $token" -H 'Content-Type: application/json' -H 'Accept: application/json, text/javascript, */*; q=0.01' --data-binary '{"revision":{"clientId":"248a328f-a133-1cd0-18c1-8997e36ef898","version":1},"component":{"id":"aab961c3-6bcd-18e7-0000-00001d74d4ea","state":"STOPPED"}}' --compressed --insecure

-

Thank you,

Matt

-

When an "Answer" addresses/solves your question, please select "Accept" beneath that answer. This encourages user participation in this forum.

Translate
daniel_amalan
Silver ⭐️⭐️⭐️
Jun 19, 2018 3:06 AM UTC

Thank you Matt.

Translate
vmurakami
Gold ⭐️
Jun 18, 2018 11:01 PM UTC

Hi @Dan Alan!
Did you check the NIFI Api Rest?
https://nifi.apache.org/docs/nifi-docs/rest-api/index.html
Hope this helps

Translate
daniel_amalan
Silver ⭐️⭐️⭐️
Jun 19, 2018 3:07 AM UTC

Thank you Vinicius.

Translate
daniel_amalan
Silver ⭐️⭐️⭐️
Oct 25, 2018 10:11 PM UTC

Hi @Matt Clarke

Is there anyway to use the encrypted password or keytab instead of passing the plain password while obtaining the token?

token=$(curl 'https://server:port/nifi-api/access/token' --data 'username=userid&password=xxxx')



Translate