Created on 06-30-2017 11:32 PM - edited on 02-23-2020 11:34 PM by VidyaSargur
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 :
[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~]#
[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:
After starting:
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:
After stopping:
Created on 07-03-2017 10:50 PM
If Nifi is on a cluster then REST API call can be sent to all nodes or just primary node?
Created on 12-07-2017 08:48 AM
As per the Nifi API documentation:
Created on 04-27-2021 01:26 PM
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?
Created on 05-03-2021 12:13 PM - edited 05-03-2021 12:15 PM
Issue has been resolved thanks alot.