Support Questions
Find answers, ask questions, and share your expertise

How can find a nifi process group id by Nifi rest api

Explorer

I have a project that try to connect nifi-api and import-export templates programatically. I can upload and delete templates succesfully but when i tried to delete related connections and controller services i realise that i don't have target process group id.

I need make some belowed calls:

  • /process-groups/{id}/controller-services
  • /process-groups/{id}/connections
  • /flow/controller/controller-services
  • /process-groups/{id} (delete)

and some other calls.

I have just xml template at first and i dont know how i can find process group {id}.

Any idea please?

1 ACCEPTED SOLUTION

Guru

hi @nzr ytmn

When you are creating a process group, you usually provide a name for it. In the API results that come back from the /process-groups/root/ call, you could look for your name, and that would provide you with the process group ID associated with it. I just created a process group in NiFi and named it "TestTemplate". I then uploaded a template from my hard drive into the process group, and made the API call. The API results show this snippet:

{"id":"e6318a1e-015c-1000-ffff-ffffe7e2554b","name":"TestTemplate", .... }

As extra validation, if I go to the NiFi UI, I can see my process group and validate that the ID matches. Therefore I think you can use the API call I suggested above if I've understood your scenario correctly.

screen-shot-2017-08-10-at-94635-am.png

View solution in original post

9 REPLIES 9

Guru

Hi @nzr ytmn

Is it not in the information returned when you call the root? Something along the lines of: http://127.0.0.1:19090/nifi-api/flow/process-groups/root/status?recursive=true

Explorer

@Sonu Sahi thanks for information, but still i am not sure how i can relate my template with process groups. I can use name of template file and compare with name of process group; but i am not sure this is good idea.

New Contributor

This will work

https://localhost:8080/nifi-api/process-groups/root/process-groups

 

This will print all the groups found in the main canvas

New Contributor

Use Case 1

How to get all the groups in the main canvas programmatically?

Answer:

url="https://localhost:8080/nifi-api/"

content_type="Content-Type: application/json"
curl -k "${url}${end_point}" -H "${content_type}" -H "${bearer}"
 
Use Case 2
How to get the groups after finding the root and it's child groups ?
For example
From the Root --> Karthik Playground ==> Csv_2_Kafka,  JSON_2_KAFKA
Karthik Playground consists of 2 process group csv_2_kafka and json_2_kafka
Root. (uuid "aaaa-bbbb"
    ==> Karthik Playground.  (uuid "cccc-dddd")
       ==> csv_2_kafka.  (uid "eeee-fff")
       ==> json_2_kafka.  (uid "gggg-hhhh")
 
  From the use case 1, we get all the UUid under Component for all the process groups in root.
  Get the uuid for karthik playground and pass like this
 

url="https://localhost:8080/nifi-api/"

content_type="Content-Type: application/json"
curl -k "${url}${end_point}" -H "${content_type}" -H "${bearer}"
 This will fetch csv_2_kafka and json_2_kafka
 
Do the same process to get the information from csv_2_kafka and json_2_kafka
 

New Contributor

Is there a single rest api call to get all process groups across all canvases?

New Contributor

New Contributor

process-group-id.png

When you select a processor group, the "Operate Palette" is populated with the process-group id. I've highlighted the location in the attached png.

,

process-group-id.png

When you clickon a process-group, the "Operate Palette" will populate the process-group id. I've highlighted it in the attached png.

Explorer

@khadijah celestine i mean find a process group id of a template programmatically with nifi api requests.

Guru

hi @nzr ytmn

When you are creating a process group, you usually provide a name for it. In the API results that come back from the /process-groups/root/ call, you could look for your name, and that would provide you with the process group ID associated with it. I just created a process group in NiFi and named it "TestTemplate". I then uploaded a template from my hard drive into the process group, and made the API call. The API results show this snippet:

{"id":"e6318a1e-015c-1000-ffff-ffffe7e2554b","name":"TestTemplate", .... }

As extra validation, if I go to the NiFi UI, I can see my process group and validate that the ID matches. Therefore I think you can use the API call I suggested above if I've understood your scenario correctly.

screen-shot-2017-08-10-at-94635-am.png

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.