Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

List existing Nifi templates using REST API

Solved Go to solution

List existing Nifi templates using REST API

New Contributor

Hello,

I am trying to write a python script to upload and instantiate templates in Nifi 1.3 using rest API.

I am able to upload the template using upload API /nifi-api/process-groups/root/templates/upload.

But I don't see a way to list all existing templates so that I can update or delete/reload templates that are already upload. I see some references to API GET /nifi-api/controller/templates in forums, but that doesn't work any more on Nifi 1.3.

Any suggestions on the write set of API calls to find and update existing Nifi templates are appreciated.

Thanks

Gopal

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: List existing Nifi templates using REST API

Contributor

Hi,

Use This

- this lists the resources in the server and formats the templates ids into a api call.

note: jq -- formats the output to be readable

curl -v -X GET http://NiFiServerIP:Port/nifi-api/resources | jq '.' | grep '"/templates/' | awk '{print $2}' | sed 's/\"//g'| sed 's/\/templates//g' | awk '{print "curl -v -X GET http://NiFiServerIP:Port/nifi-api/templates"$1"/download"}'

The output should be a Rest Api call:

curl -v -X GET http://NiFiServerIP:Port/nifi-api/templates/885dc02e-cb13-429c-bdvd-9a4e0cbe1212b/download

In the future if you don`t see how is done in the docs you can always SPY on the nifi-app.log, it gives you what you need to know.

Hope this helped.

2 REPLIES 2
Highlighted

Re: List existing Nifi templates using REST API

Contributor

Hi,

Use This

- this lists the resources in the server and formats the templates ids into a api call.

note: jq -- formats the output to be readable

curl -v -X GET http://NiFiServerIP:Port/nifi-api/resources | jq '.' | grep '"/templates/' | awk '{print $2}' | sed 's/\"//g'| sed 's/\/templates//g' | awk '{print "curl -v -X GET http://NiFiServerIP:Port/nifi-api/templates"$1"/download"}'

The output should be a Rest Api call:

curl -v -X GET http://NiFiServerIP:Port/nifi-api/templates/885dc02e-cb13-429c-bdvd-9a4e0cbe1212b/download

In the future if you don`t see how is done in the docs you can always SPY on the nifi-app.log, it gives you what you need to know.

Hope this helped.

Re: List existing Nifi templates using REST API

New Contributor

That works perfectly! Thanks!

Don't have an account?
Coming from Hortonworks? Activate your account here