Created 12-18-2017 04:42 PM
Created 12-18-2017 06:47 PM
Upload means Copying (or) uploading the template .XML file into the instance of NiFi.
Once the template is uploaded then the template is ready to be instantiated to the NiFi Canvas.
Import means Loading the copied (or) uploaded .XML file into NiFi Canvas(into root or process group).
Let's consider
You have created a flow in DEV env and then you need to promote this flow to PROD env,
For this case we are going to create a Template in DEV env first, then download the template into local.
Then you are going to Upload the the template to PROD env first so the template will be available in PROD env now.
To add the uploaded template to the NiFi Canvas then you need to import the template.
Created 12-18-2017 06:47 PM
Upload means Copying (or) uploading the template .XML file into the instance of NiFi.
Once the template is uploaded then the template is ready to be instantiated to the NiFi Canvas.
Import means Loading the copied (or) uploaded .XML file into NiFi Canvas(into root or process group).
Let's consider
You have created a flow in DEV env and then you need to promote this flow to PROD env,
For this case we are going to create a Template in DEV env first, then download the template into local.
Then you are going to Upload the the template to PROD env first so the template will be available in PROD env now.
To add the uploaded template to the NiFi Canvas then you need to import the template.
Created 12-18-2017 08:44 PM
Thank you @Shu
I was able to upload to my NiFi instance using following curl:
curl -XPOST http://<nifihost:nifiport>/nifi-api/process-groups/<id>/templates/upload -k -v -F template=@/path/to/template.xml
I am now tryin to import into NiFi Canvas but am unable to formulate the right command for this. Can you help me with correct curl to import the uploaded template onto the canvas?
Created 12-19-2017 04:30 AM
To import the Template into NiFi Canvas we need to use specific syntax of curl command and template-instance
curl -i -X POST -H 'Content-Type:application/json' -d '{"originX": 2.0,"originY": 3.0,"templateId": "<template-id>"}' http://localhost:8080/nifi-api/process-groups/<process-group-id>/template-instance
Here is what i tried
I'm having a template in my Downloads folder
1.To upload a template from Downloads folder to NiFi i used below curl with upload method
curl -X POST http://localhost:8080/nifi-api/process-groups/226b1e5f-0160-1000-deb0-791f1a6f1f00/templates/upload -k -v -F template=@/cygdrive/c/shu/Downloads/Count_Loop.xml
in the above curl i'm using POST and my process group id is 226b1e5f-0160-1000-deb0-791f1a6f1f00
??Why we need to specify process group id while uploading??
Templates are owned by a process group (whether that is the root process group or one nested in the canvas). You can upload templates by making use of the '/process-groups/{id}/templates/upload' to upload a template to a particular process group.
Then i have given the path to the my Count_Loop.xml file and uploaded the template into NiFi Instance.
2.Now we need to import the Uploaded Count_Loop.xml into NiFi canvas
For this case we need to have our Template ID, For this id
Curl http://localhost:8080/nifi-api/flow/templates
Hit the above API and get the Template id for the Uploaded template for my case my template id is 02a4b939-ac14-4fac-9f05-550cc521b317.
Then we need to instantiate the template by using POST method and template-instance
POST /process-groups/{id}/template-instance
My command is as follows
curl -i -X POST -H 'Content-Type:application/json' -d '{"originX": 2.0,"originY": 3.0,"templateId": "02a4b939-ac14-4fac-9f05-550cc521b317"}' http://localhost:8080/nifi-api/process-groups/226b1e5f-0160-1000-deb0-791f1a6f1f00/template-instance
i'm importing the uploaded Count_Loop.xml into the ProcessGroupID 226b1e5f-0160-1000-deb0-791f1a6f1f00 ,we got template id before so i'm using the TemplateID 02a4b939-ac14-4fac-9f05-550cc521b317 in the above curl method.
This template instance expects origin x, y and template id for sure. If you are missing any of these parameters then it results Bad request error.
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 errors.
Created 12-19-2017 07:59 PM
Thank you @Shu
Created 04-04-2019 06:39 PM
I understand in Upload and Import there will be always a template copy created for any flow that has to be imported to the canvas.
Scenario:
I have one flow (xml), I will have to create ten copies/instance of this flow (with different source/target).
I know we can import ten times from one template after uploading (one time) and then update the variables again by Rest API.
But I want to update the parameters/variables in xml file itself and then directly import to canvas for some reasons. Is it possible ?