Support Questions

Find answers, ask questions, and share your expertise

Import Json Definition to a target nifi system using Rest API of NiFi 2.0.0-M4

avatar
New Contributor

Hi All,
I have created my processor group in a local instance of NiFi 2.0.0-M4 and I have downloaded the json definition file and also I can able to import that json manually to a target nifi system (production), but my ultimate goal is to deploy this json using NiFi RestAPI and I have accomplished the following tasks
1. Generate the NiFi Token
2. Create a ProcessorGroup to the target NiFi system

But I could not find a way to import the json definition file through REST API and when I search on the apache NiFi documentation of API and in could not find any proper api call for NiFi version 2.0.0-M4 but there is only for version 1.28 supported Api endpoints for template concepts but as of NiFi version 2.0.0-M4 it was changed from xml template into json definition concept. Now how do I import the json file to the target system processGroup which i created through rest api.

Please anyone can give your suggestion asap.
Thanks
Vijay.AX

2 ACCEPTED SOLUTIONS

avatar
Master Mentor

@AllIsWell 

Welcome to the community.

NiFi templates where deprecated long ago in the Apache NiFi 1.x version as well.
They were officially completely removed from the product in Apache NiFi 2.x.

Flow Definitions which are in json format can be downloaded and uploaded to both newer version of Apache NiFi 1.x and all versions of Apache NiFi 2.x.

The rest-api docs cover upload of a flow defintion here:
https://nifi.apache.org/nifi-docs/rest-api.html#uploadProcessGroup

There are 6 form fields:

MattWho_0-1741098355694.png

An example rest-api call would look something like this:

curl 'https://<nifi-hostname>:<nifi-port>/nifi-api/process-groups/<uuid of Process group in which flow definition will be uploaded>/process-groups/upload' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'content-type: multipart/form-data' \
  -H 'Authorization: Bearer <TOKEN>' \
  --form 'clientId="<uuid of Process group in which flow json will be uploaded>"' \
  --form 'disconnectedNodeAcknowledged="false"' \
  --form 'file=@"/<path to>/<flow-defintion.json filename>"' \
  --form 'groupName="handleHTTPRequestFlow2c"' \
  --form 'positionX="361"' \
  --form 'positionY="229.5"' \
  --insecure

 I use ldap to authenticate in to my NiFi, so i use the bearer token issues for my user on authentication in the above rest-api call. 

Please help our community grow and 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

View solution in original post

avatar
New Contributor

Hi Matt,
Thank you so much for the solution you provided and  you saved my day. It is working fine.
Thanks
Vijay

View solution in original post

2 REPLIES 2

avatar
Master Mentor

@AllIsWell 

Welcome to the community.

NiFi templates where deprecated long ago in the Apache NiFi 1.x version as well.
They were officially completely removed from the product in Apache NiFi 2.x.

Flow Definitions which are in json format can be downloaded and uploaded to both newer version of Apache NiFi 1.x and all versions of Apache NiFi 2.x.

The rest-api docs cover upload of a flow defintion here:
https://nifi.apache.org/nifi-docs/rest-api.html#uploadProcessGroup

There are 6 form fields:

MattWho_0-1741098355694.png

An example rest-api call would look something like this:

curl 'https://<nifi-hostname>:<nifi-port>/nifi-api/process-groups/<uuid of Process group in which flow definition will be uploaded>/process-groups/upload' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'content-type: multipart/form-data' \
  -H 'Authorization: Bearer <TOKEN>' \
  --form 'clientId="<uuid of Process group in which flow json will be uploaded>"' \
  --form 'disconnectedNodeAcknowledged="false"' \
  --form 'file=@"/<path to>/<flow-defintion.json filename>"' \
  --form 'groupName="handleHTTPRequestFlow2c"' \
  --form 'positionX="361"' \
  --form 'positionY="229.5"' \
  --insecure

 I use ldap to authenticate in to my NiFi, so i use the bearer token issues for my user on authentication in the above rest-api call. 

Please help our community grow and 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

avatar
New Contributor

Hi Matt,
Thank you so much for the solution you provided and  you saved my day. It is working fine.
Thanks
Vijay