Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Unable to update/execute processor though NIFI rest API in NIFI 1.0.0

avatar
Rising Star

Background:We are using Apache NIFI data flow to move data local from to Hadoop based file systems.We are executing the NIFI processors by calling the NIFI rest API using groovy script wherein we use json builders in groovy to generate the Json and then passing the json to put methods to execute the processors. NIFI Version:0.6.0

While planning to migrate to NIFI 1.0.0 and using the same groovy script we are facing a few errors in the latest version of NIFI(1.0.0):

  1. Having controller/revision in nifi.get method does not return the response json, instead its throwing 404, verified in browser too. This works fine in 0.6.1 Nifi version. Reference : resp = nifi.get(path: 'controller/revision')
  2. This below does not work too, since having controller in path as a pretext to process-groups is no longer valid. It also returns a 404/bad request error.This works fine in 0.6.1 Nifi version Reference : resp = nifi.put( path: "controller/process-groups/$processGroup/processors/$processorId", body: builder.toPrettyString(), requestContentType: JSON )
  3. PS: While trying to verify the below in browser, GET only responds when we have structures like /process-groups/{id} or /process-groups/{id}/processors , i.e. without controller string.This works fine in 0.6.1 Nifi version Reference: host://port/nifi-api/process-groups/root
  4. Below syntax does not work in script either. This works fine in 0.6.1 Nifi version resp = nifi.put( path: "process-groups/$processGroup/processors/$processorId", body: builder.toPrettyString(), requestContentType: JSON )

Since the syntax provided above works perfectly fine in 0.6.0 I would like to know if any changes are made in NIFI 1.0.0 in the rest API or in the way the various HTTP requests are passed to methods like 'get' and 'put'?

I could not find any changes in the release notes or the NIFI API documentation provided in the link below:

https://nifi.apache.org/docs/nifi-docs/rest-api/

Please let me know if you need any other information.

Regards,

Indranil Roy

1 ACCEPTED SOLUTION

avatar
Rising Star

Indranil Roy,

For Apache NiFi 1.0.0 the REST API was completely refactored to promote multi-tenancy. Specifically, the endpoints have been reorganized to align with the resources being authorized and component specific revisions have been introduced. I would highly recommend using the Developer Tools in your browser to see the APIs in action. Here is an example curl commend for starting a processor.

curl 'http://localhost:8080/nifi-api/processors/2a817541-0158-1000-771e-93ca6d670429' -X PUT -H 'Content-Type: application/json' -H 'Accept: application/json, text/javascript, */*; q=0.01' --data-binary '{"revision":{"clientId":"2a81087c-0158-1000-1362-5452a699615c","version":3},"component":{"id":"2a817541-0158-1000-771e-93ca6d670429","state":"RUNNING"}}'

In order to get the revision details for this component it would be available in the flow returned for a given process group. Here's an example of that curl commend.

curl 'http://localhost:8080/nifi-api/flow/process-groups/<process-group-id>'

View solution in original post

6 REPLIES 6

avatar
Rising Star

Indranil Roy,

For Apache NiFi 1.0.0 the REST API was completely refactored to promote multi-tenancy. Specifically, the endpoints have been reorganized to align with the resources being authorized and component specific revisions have been introduced. I would highly recommend using the Developer Tools in your browser to see the APIs in action. Here is an example curl commend for starting a processor.

curl 'http://localhost:8080/nifi-api/processors/2a817541-0158-1000-771e-93ca6d670429' -X PUT -H 'Content-Type: application/json' -H 'Accept: application/json, text/javascript, */*; q=0.01' --data-binary '{"revision":{"clientId":"2a81087c-0158-1000-1362-5452a699615c","version":3},"component":{"id":"2a817541-0158-1000-771e-93ca6d670429","state":"RUNNING"}}'

In order to get the revision details for this component it would be available in the flow returned for a given process group. Here's an example of that curl commend.

curl 'http://localhost:8080/nifi-api/flow/process-groups/<process-group-id>'

avatar
Rising Star

thank you so much.. i had issues with this curl dude.. had been searching for the correct command for over 3 days.. its working now.. 😄

avatar
Rising Star

where can I get this entire documentation? What if I want to run a Process-Group ?

avatar
Rising Star

The documentation is the link that you already have. However, I would suggest checking out the Developer Tools in your browser. The UI uses the REST API for all interactions with the framework. The Developer Tools even allows for you to copy the command as a cUrl command.

Here's the command for starting a Process Group.

curl 'http://localhost:8080/nifi-api/flow/process-groups/232d4ab5-0159-1000-1962-8a2afbbe9dc9' -X PUT -H 'Accept-Encoding: gzip, deflate, sdch, br' -H 'Content-Type: application/json' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Referer: http://localhost:8080/nifi/' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' --data-binary '{"id":"232d4ab5-0159-1000-1962-8a2afbbe9dc9","state":"RUNNING"}' --compressed

avatar
Rising Star

thank you so so much.. i can enjoy holidays now knowing this has been taken care of.. Happy Holidays to you 🙂 will surely research on Dev Tools

avatar

the above command works as a curl perfectly. can we achieve the same from the nifi processors? I am trying with InvokeHTTP and POSTHTTP but where do we need to specify the data-binary values in the processors?