Support Questions

Find answers, ask questions, and share your expertise

How to change the nifi processor properties with nifi rest api?

avatar
Contributor

I have been trying to change the GetFile processor properties (Input Directory,keep resource file...etc) using rest api call but getting below response :

Command:

curl -i -X PUT -H 'Content-Type: application/json' -d '{"revision":{"version":3,"clientId":"5f10fbca-0166-1000-ae68-13829a991131"},"processor":{"id":"1ffcfa18-0165-1000-ffff-ffffa779f243","parentGroupId":"1fe8ebbf-0165-1000-0000-00003595dafd","config":{"properties":{"Input Directory":"/tmp/hortontest"}}}}' http://node1:9090/nifi-api/controller/process-groups/1fe8ebbf-0165-1000-0000-00003595dafd/processors...

Output:

HTTP/1.1 404 Not Found Date: Thu, 11 Oct 2018 13:48:40 GMT X-Frame-Options: SAMEORIGIN Content-Type: text/plain Vary: Accept-Encoding Content-Length: 42 Server: Jetty(9.4.3.v20170317) The specified resource could not be found.

1 ACCEPTED SOLUTION

avatar

@Veerendra Nath Jasthi

Yeah, that doesn't work because our format should be slightly different. Try this, I just tested and it works fine;

curl -i -X PUT -H 'Content-Type: application/json' http://<nifi-host>:9090/nifi-api/processors/6391462d-0166-1000-0000-000002b215e0 -d '{"revision":{"clientId":"63911e66-0166-1000-3f04-f0e4a96a47da","version":"4"},"component":{"id":"6391462d-0166-1000-0000-000002b215e0","config":{"properties":{"Input Directory":"/some/new/dir"}}}}'

PS. if you found my answers helpful, please click accept answer 🙂

View solution in original post

6 REPLIES 6

avatar

Hi @Veerendra Nath Jasthi

I've tried this myself just now, by first exporting the current settings like so;

curl -X GET -H 'Content-Type: application/json' http://nifibox:9090/nifi-api/processors/6391462d-0166-1000-0000-000002b215e0 | python -m json.tool > /tmp/processorconfig.json

And then from the resulting json output, I modify the directory listed and post it back like so;

curl -X PUT -H 'Content-Type: application/json' http://nifibox:9090/nifi-api/processors/6391462d-0166-1000-0000-000002b215e0 -d @processorconfig.json

BTW, specifying the processor ID alone on the PUT operation is enough - even if the processor is part of a different process group the above example still works.

avatar
Contributor

Thanks for quick response Jon. Is the only way I could do that or are any other ways I can modify the processor properties with rest api calls ?

avatar

avatar
Contributor

@Jonathan Sneep

https://community.hortonworks.com/articles/87217/change-nifi-flow-using-rest-api-part-1.html as per step 7 I used the below command :

curl -X PUT -H 'Content-Type: application/json' -d '{"component":{"id":"1ffd1b86-0165-1000-ffff-ffffe8f36d71","name":"GetFile","config":{"Input Directory":"/tmp/hortontest","Keep Source File":"false"},"revision":{"clientId":"5f10fbca-0166-1000-ae68-13829a991131","version":2}}' http://nifinode:9090/nifi-api/processors/1ffcfa18-0165-1000-ffff-ffffa779f243

Output:

Unrecognized field "Input Directory" (class org.apache.nifi.web.api.dto.ProcessorConfigDTO), not marked as ignorable (17 known properties: "yieldDuration", "descriptors", "runDurationMillis", "concurrentlySchedulableTaskCount", "schedulingStrategy", "autoTerminatedRelationships", "customUiUrl", "lossTolerant", "properties", "comments", "schedulingPeriod", "defaultConcurrentTasks", "annotationData", "executionNode", "penaltyDuration", "defaultSchedulingPeriod", "bulletinLevel"]) at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 105] (through reference chain: org.apache.nifi.web.api.entity.ProcessorEntity["component"]->org.apache.nifi.web.api.dto.ProcessorDTO["config"]->org.apache.nifi.web.api.dto.ProcessorConfigDTO["Input Directory"])

avatar

@Veerendra Nath Jasthi

Yeah, that doesn't work because our format should be slightly different. Try this, I just tested and it works fine;

curl -i -X PUT -H 'Content-Type: application/json' http://<nifi-host>:9090/nifi-api/processors/6391462d-0166-1000-0000-000002b215e0 -d '{"revision":{"clientId":"63911e66-0166-1000-3f04-f0e4a96a47da","version":"4"},"component":{"id":"6391462d-0166-1000-0000-000002b215e0","config":{"properties":{"Input Directory":"/some/new/dir"}}}}'

PS. if you found my answers helpful, please click accept answer 🙂

avatar
Contributor

@avatar image

Jonathan Sneep

Thank you so much for help it is working now.....