Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Stop Controller Service in nifi using rest api

avatar

Hi Team,

I was able to ENABLE and update a controller-service in nifi using rest api.

But I'm not able to DISABLE the controller-service using rest api.

I'm doing a put to end point: "http://localhost:9090/nifi-api/controller-services/{MyControllerID}"

My payload: {"component":{"id":'controllerID',"name":"DBCPConnectionPool", 'state': 'DISABLED'},"revision":{"clientId":client,"version":11}}

Kindly help me if I'm missing out anything here.

4 REPLIES 4

avatar
Master Guru

@Nikhil R

In your pay load you have to include your client id number for the controllerservice.

Example:-

I'm having a controller service in my nifi instance and we need to get the clientId for the controller service.

Step1:How to find clientId value?

To find out client id and version number use Developer tools (chrome, firefox etc) and perform any action (start, stop ...etc) for the controller service and look at the calls made for the Controller service id.

for reference take a look in the below screenshot

68419-restapi.png

Click on Network

2.In filter keep your controller service id

3.Click on Response then you can find clientid,version

Once you get all the values prepare your curl command to stop Controller Service.

As my controllerservice id is c8b1c581-47f0-3773-e7a5-3eb739246f99 so i filtered out only this specific id and then go to any of the Put methods and go to Params tab on right side then you can get the clientId associated with the controllerservice.

Step2:Prepare PayLoad
Now include your clientid value in your payload,

from the above screenshot my clientId value is af22b3ab-0162-1000-9b81-cf7b337dfc47 so i have included the same clientId in my payload and included my componentid i.e our controller service id

{"revision":{"clientId":"af22b3ab-0162-1000-9b81-cf7b337dfc47","version":1},"component":{"id":"c8b1c581-47f0-3773-e7a5-3eb739246f99","state":"DISABLED"}}

Step3:Prepare Curl api call:-

Now we need to include payload and end point in one curl call.

Use put method and the state as DISABLED(as we need to disable the controller service) in curl call.

Curl api call:-

curl -i -X PUT -H 'Content-Type:application/json' -d '{"revision":{"clientId":"af22b3ab-0162-1000-9b81-cf7b337dfc47","version":1},"component":{"id":"c8b1c581-47f0-3773-e7a5-3eb739246f99","state":"DISABLED"}}' http://localhost:9090/nifi-api/controller-services/c8b1c581-47f0-3773-e7a5-3eb739246f99 

Once the api call is success then you can receive 200 response code and the controller service will be disabled.

For your case change the the clientid and controllerserviceid make rest api call to disable the controller service.

.

If the Answer helped to resolve your issue, Click on Accept button below to accept the answer, That would be great help to Community users to find solution quickly for these kind of issues.

avatar
Master Guru

@Nikhil R

{"component":{"id":'controllerID',"name":"DBCPConnectionPool", 'state': 'DISABLED'},"revision":{"clientId":client,"version":11}}

Change the quotes in your json payload keep everything in double quotes don't use single quotes.

{"revision":{"clientId":"af22b3ab-0162-1000-9b81-cf7b337dfc47","version":1},"component":{"id":"c8b1c581-47f0-3773-e7a5-3eb739246f99",'state':'DISABLED'}}

avatar

Hi,

While sending the request I'm passing a proper payload, I just mentioned here ClientID as 'client' whereas in my payload I'm passing my clientID.

Also I can see that the payload mentioned is identical with mine which am using.

Is there any other thing we need to disable before disabling the controller service?

Kindly let me know

avatar

I got the issue resolved.

The Issue is we cannot disable the service immediately after stopping the process group via rest api.

I'm putting it to sleep for 2 mins and then sending a request to disable the service and its working fine.

Thanks a lot for responding