Community Articles

Find and share helpful community-sourced technical articles.
Labels (1)
avatar
Rising Star

For non-SSL enabled NiFi below should work:

curl --tlsv1.2 -i -H
'Content-Type: application/json' -XPUT -d
'{"id":"cdb54c9a-0158-1000-5566-c45ca9692f85","state":"RUNNING"}'
localhost:8080/nifi-api/flow/process-groups/cdb54c9a-0158-1000-5566-c45ca9692f85

Start Process Group for SSL enabled NiFi :

  • Generate access token:
[root@nifi-ambari-01
~]# curl --tlsv1.2  https://000.00.00.000:9091/nifi-api/access/token
--data 'username=awadhwani&password=password' -k

O/P:

eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJjbj1BcnRpIFdhZGh3YW5pLG91PVBlb3BsZSxkYz1zbWUsZGM9aHd4IiwiaXNzIjoiTGRhcFByb3ZpZGVyIiwiYXVkIjoiTGRhcFByb3ZpZGVyIiwicHJlZmVycmVkX3VzZXJuYW1lIjoiQXJ0aSBXYWRod2FuaSIsImtpZCI6MywiZXhwIjoxNDg5MjMyNDQyLCJpYXQiOjE0ODkxODkyNDJ9.17iHL3XX7Bw6dXv5lCByimu_asQOaSwW11o2IQEFO0s[root@nifi-ambari-01~]#
  • Start PG by passing the above access token
[root@nifi-ambari-01
~]# curl --tlsv1.2 -ik -H 'Content-Type: application/json' -H 'Authorization:
Bearer
eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJjbj1BcnRpIFdhZGh3YW5pLG91PVBlb3BsZSxkYz1zbWUsZGM9aHd4IiwiaXNzIjoiTGRhcFByb3ZpZGVyIiwiYXVkIjoiTGRhcFByb3ZpZGVyIiwicHJlZmVycmVkX3VzZXJuYW1lIjoiQXJ0aSBXYWRod2FuaSIsImtpZCI6MywiZXhwIjoxNDg5MjMyNDQyLCJpYXQiOjE0ODkxODkyNDJ9.17iHL3XX7Bw6dXv5lCByimu_asQOaSwW11o2IQEFO0s'
-XPUT -d
'{"id":"2f092b07-0157-1000-0000-00005f526fbc","state":"RUNNING"}'
https://000.00.00.000:9091/nifi-api/flow/process-groups/2f092b07-0157-1000-0000-00005f526fbc

O/P:

HTTP/1.1 200 OKDate: Fri, 10 Mar
2017 23:42:14 GMTServer:
Jetty(9.3.9.v20160517)Cache-Control:
private, no-cache, no-store, no-transformX-ProxiedEntitiesAccepted:
trueDate: Fri, 10 Mar
2017 23:42:14 GMTContent-Type:
application/jsonContent-Length: 63{"id":"2f092b07-0157-1000-0000-00005f526fbc","state":"RUNNING"}[root@nifi-ambari-01
~]#

Earlier before starting:

16659-before-starting.png

After starting:

16660-after-starting.png

Stop process Group for SSL enabled NiFi :

(use the same token generated above)

[root@nifi-ambari-01
~]# curl --tlsv1.2 -ik -H 'Content-Type: application/json' -H 'Authorization:
Bearer
eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJjbj1BcnRpIFdhZGh3YW5pLG91PVBlb3BsZSxkYz1zbWUsZGM9aHd4IiwiaXNzIjoiTGRhcFByb3ZpZGVyIiwiYXVkIjoiTGRhcFByb3ZpZGVyIiwicHJlZmVycmVkX3VzZXJuYW1lIjoiQXJ0aSBXYWRod2FuaSIsImtpZCI6MywiZXhwIjoxNDg5MjMyNDQyLCJpYXQiOjE0ODkxODkyNDJ9.17iHL3XX7Bw6dXv5lCByimu_asQOaSwW11o2IQEFO0s'
-XPUT -d
'{"id":"2f092b07-0157-1000-0000-00005f526fbc","state":"STOPPED"}'
https://000.00.00.000:9091/nifi-api/flow/process-groups/2f092b07-0157-1000-0000-00005f526fbc
HTTP/1.1 200 OKDate: Fri, 10 Mar
2017 23:42:46 GMTServer:
Jetty(9.3.9.v20160517)Cache-Control:
private, no-cache, no-store, no-transformX-ProxiedEntitiesAccepted:
trueDate: Fri, 10 Mar
2017 23:42:46 GMTContent-Type:
application/jsonContent-Length: 63{"id":"2f092b07-0157-1000-0000-00005f526fbc","state":"STOPPED"}[root@nifi-ambari-01
~]

Earlier before stopping:

16655-before-stopping.png

After stopping:

16656-after-stopping.png

14,818 Views
Comments
avatar
Contributor

If Nifi is on a cluster then REST API call can be sent to all nodes or just primary node?

avatar
Contributor

As per the Nifi API documentation:

GET /process-groups/{groupId}/variable-registry/update-requests/{updateId} Gets a process group's variable registry
DELETE /process-groups/{groupId}/variable-registry/update-requests/{updateId} Deletes an update request for a process group's variable registry. If the request is not yet complete, it will automatically be cancelled.
GET /process-groups/{id} Gets a process group
PUT /process-groups/{id} Updates a process group
But, the call is /nifi-api/flow/process-groups. Any idea if this is a documentation issue ?
avatar
New Contributor

Hi All,

 

We are using nifi 1.8 and it was on http, we enabled https now on 3 node cluster.

We have processers which we had to start and stop based on feeds from upstream systems and other checks. We used api as suggested in post. Below is code

 

tkn=$(curl --tlsv1.2 https://10.10.10.10:8443/nifi-api/access/token --data 'username=USERID&password=PASSWORD' -k)

GETFILE='https://'$HOSTNAME':'$PORT'/nifi-api/processors/'$GET_ID''

curl --tlsv1.2 -ik -H 'Content-Type: application/json' -H 'Authorization: Bearer '$tkn'' -X PUT -d '{"id":"'$GET_ID'","state":"RUNNING"}}' $GETFILE

 

When i execute i get below error, but when i try from console for this user i can start and stop the processer 'ddd43f1f-015f-1000-10d9-dfb3420f4d4c'

 

tkn=$(curl --tlsv1.2 https://10.10.10.10:8443/nifi-api/access/token --data 'username=USERID&password=PASSWORD' -k)

+ curl --tlsv1.2 https://10.10.10.10:8443/nifi-api/access/token --data 'username=USERID&password=PASSWORD' -k
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 307 100 260 100 47 816 147 --:--:-- --:--:-- --:--:-- 833

tkn=eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzcnZBUDEyMDE0MkRFViIsImlzcyI6IkxkYXBQcm92aWRlciIsImF1ZCI6IkxkYXBQcm92aWRlciIsInByZWZlcnJlZF91c2VybmFtZSI6InNydkFQMTIwMTQyREVWIiwia2lkIjoxLCJleHAiOjE2MTk1OTc1NjksImlhdCI6MTYxOTU1NDM2OX0.v9rLE9ujUgoKe-zRe-aeW4_6PJn8ozNN6-LT2Sv1Ufo

GETFILE=https://10.10.10.10:8443/nifi-api/processors/ddd43f1f-015f-1000-10d9-dfb3420f4d4c

curl --tlsv1.2 -ik -H 'Content-Type: application/json' -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzcnZBUDEyMDE0MkRFViIsImlzcyI6IkxkYXBQcm92aWRlciIsImF1ZCI6IkxkYXBQcm92aWRlciIsInByZWZlcnJlZF91c2VybmFtZSI6InNydkFQMTIwMTQyREVWIiwia2lkIjoxLCJleHAiOjE2MTk1OTc1NjksImlhdCI6MTYxOTU1NDM2OX0.v9rLE9ujUgoKe-zRe-aeW4_6PJn8ozNN6-LT2Sv1Ufo' -X PUT -d '{"id":"ddd43f1f-015f-1000-10d9-dfb3420f4d4c","state":"RUNNING"}}' https://10.10.10.10:8443/nifi-api/processors/ddd43f1f-015f-1000-10d9-dfb3420f4d4c

HTTP/1.1 400 Bad Request
Date: Tue, 27 Apr 2021 20:12:49 GMT
X-Frame-Options: SAMEORIGIN
Content-Security-Policy: frame-ancestors 'self'
Content-Type: text/plain
Vary: Accept-Encoding
Content-Length: 498
Server: Jetty(9.4.11.v20180605)

 Can you please advise what i am missing or doing wrong?

avatar
New Contributor

Issue has been resolved thanks alot.