Created on 08-04-2024 10:48 AM - edited 08-04-2024 10:51 AM
Templates are deprecated from 2.X
I have existing nifi process groups in the form of exported .json files
Below is the requirement for REST API:
1. Create process group using exported .json file if not exist
2. Update existing process group
I am able to uplod to existing process group using below curl:
curl --location 'https://localhost:8443/nifi-api/process-groups/1e373804-0191-1000-e950-856de82e267d/process-groups/u...' \
--header 'Cookie: __Secure-Request-Token=2dae7036-f4c3-4115-9865-6c9d7984dfa8' \
--header 'Authorization: Bearer esometoken3M' \
--form 'positionX="11.0"' \
--form 'clientId="11"' \
--form 'disconnectNode="false"' \
--form 'groupName="empty"' \
--form 'positionY="557.0"' \
--form 'file=@"/home/gwl/Downloads/existing-flow.json"'
But when i try to upload completely new process group using below curl:
curl --location 'https://localhost:8443/nifi-api/process-groups/01911000-3804-1e37-10a0-827d946513c6/process-groups/u...' \
--header 'Cookie: __Secure-Request-Token=2dae7036-f4c3-4115-9865-6c9d7984dfa8' \
--header 'Authorization: Bearer eyJraWQE3MjI3ODc2ODksImlzcyI6Imh0dHBzOi8vMTI3LjAuMC4xOjg0NDMiLCJncm91cNr3F1fuSJ4dtIymm4qB7OwWRrLUiRq-qMB3GTqR8Tvg_CZ6kHsYuyNEGWF9g1nnmEVvd0bQ5ok-wChtM82G1Fud3DfBjFH6-Uzeb-L47assCIL1dzMD2KyC-5HpuTHF3M' \
--form 'positionX="11.0"' \
--form 'clientId="11"' \
--form 'disconnectNode="false"' \
--form 'groupName="empty"' \
--form 'positionY="557.0"' \
--form 'file=@"/home/gwl/Downloads/new-flow.json"'
It gives me below error:
An unexpected error has occurred. Please check the logs for additional details.
The log output from nifi-user.log is:
Created 08-05-2024 09:00 AM
@DeepakDonde
I may not be completely clear on what you have tried above. I am not sure what you mean by "completely new process group". The rest-api endpoints used in both commands above are the same except each has a unique process group UUID:
1e373804-0191-1000-e950-856de82e267d <-- worked
01911000-3804-1e37-10a0-827d946513c6 <-- did not work
The second throws an exception that implies the process-group with that UUID does not exist. That uuid needs to be the uuid of the process group in which you are uploading your flow definition. A flow definition will consist of a Process Group (PG) that normally contains components. I am guessing that the UUID you shared that did not work is some random uuid you created? When you flow definition is uploaded to the NiFi UI, its PG and components are assigned UUIDs. You can upload the same flow definition multiple times and each time all components get new UUIDs.
NiFi Flow Definitions can only be created by right clicking on a Process Group and selecting "Download flow Definition" from the displayed context menu or via the equivalent rest-api endpoint. That flow definition is stored as a json file which can later be uploaded to the canvas of the same NiFi or to another NiFi.
A flow definition is uploaded only by specifying the process group you want upload the flow definition to and the x and y coordinates at which the flow definition's Process Group will be placed. It is not possible to upload a flow definition without this valid information.
Even a freshly installed NIFi will generate a root process group on first startup. When you access the UI of a new NiFi install, the blank canvas you are presented with is the root process group and has an assigned UUID (uuid is shown in the "operate" panel in left side of the canvas). Form that root process group you can add many levels of chid process groups and can upload a flow definition to the root process group or any child process group level.
Please help our community thrive. If you found any of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "Accept as Solution" on one or more of them that helped.
Thank you,
Matt
Created 08-05-2024 09:00 AM
@DeepakDonde
I may not be completely clear on what you have tried above. I am not sure what you mean by "completely new process group". The rest-api endpoints used in both commands above are the same except each has a unique process group UUID:
1e373804-0191-1000-e950-856de82e267d <-- worked
01911000-3804-1e37-10a0-827d946513c6 <-- did not work
The second throws an exception that implies the process-group with that UUID does not exist. That uuid needs to be the uuid of the process group in which you are uploading your flow definition. A flow definition will consist of a Process Group (PG) that normally contains components. I am guessing that the UUID you shared that did not work is some random uuid you created? When you flow definition is uploaded to the NiFi UI, its PG and components are assigned UUIDs. You can upload the same flow definition multiple times and each time all components get new UUIDs.
NiFi Flow Definitions can only be created by right clicking on a Process Group and selecting "Download flow Definition" from the displayed context menu or via the equivalent rest-api endpoint. That flow definition is stored as a json file which can later be uploaded to the canvas of the same NiFi or to another NiFi.
A flow definition is uploaded only by specifying the process group you want upload the flow definition to and the x and y coordinates at which the flow definition's Process Group will be placed. It is not possible to upload a flow definition without this valid information.
Even a freshly installed NIFi will generate a root process group on first startup. When you access the UI of a new NiFi install, the blank canvas you are presented with is the root process group and has an assigned UUID (uuid is shown in the "operate" panel in left side of the canvas). Form that root process group you can add many levels of chid process groups and can upload a flow definition to the root process group or any child process group level.
Please help our community thrive. If you found any of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "Accept as Solution" on one or more of them that helped.
Thank you,
Matt
Created 08-05-2024 09:53 PM
I get it now. The NIFI has root process group which can be used to upload new process groups.
I am using headless NIFI, is there any way to get root process group ID? I dont have access to NIFI UI canvas
Created 08-06-2024 05:58 AM
@DeepakDonde
Please share more details on your "headless" NiFi setup. NiFi version and configuration.
Or are you using MiNiFi?
Created on 08-06-2024 06:54 AM - edited 08-06-2024 06:57 AM
The term "headless" means that "I have access to NIFI server through REST API only!"
Anyways, I used below curl to get root level process group:
curl --location 'https://localhost:8443/nifi-api/process-groups/root' \
--header 'Authorization: Bearer eyJraWQiOiI1NGU4ZWRkNi00ZTY1LTQ3MmUtYTI5Ni1mNmI3MDJjZDYzNWEiLCJhbGciOiJQUzUxMiJ9.eyJzdWIiOiJkZWVwYWtkb2
I am closing this thread