Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 01-23-2018 02:45 PM
Hi, I just started with NiFi. I've been looking for two days without success the answer to my problem. There it goes:
I have a EvaluateJsonPath that returns into an JSON NiFi Attribute some objects id in that way : [0, 1, 2, 3, 4, 5, 6, ...]. I would wish to create a processor (InvokeHttp) for each id dynamically. After that, each created processor should take the id from the JSON to generate the url.
How do i face it?? Thank you so much.
Created 01-23-2018 05:45 PM
What you will want to do is split your original JSON into a flow file per id, and then send them all to a single InvokeHttp processor and reference a variable in URL of InvokeHttp. Here is a high-level of how it might work...
Lets say starting JSON is:
{ "ids" : [ "1", "2", "3" ] }First use SplitJson processor with a Json Path of $.ids, this will produce 3 flow files where the content of each is 1, 2, and 3 respectively.
Second, use ExtractText processor.. add a user defined property with the name "my.id" and the value of (.*)
That will extract the content of each flow file into an attribute called my.id.
Finally, in InvokeHttp set the Remote URL to http://yourhost/path/${my.id}
When InvokeHttp processors a flow file, it will evaluate Remote URL against the incoming flow file attributes, and replace ${my.id} with the value of that attribute on the particular flow file, which in this case will be 1, 2, or 3.
Created 01-23-2018 05:45 PM
What you will want to do is split your original JSON into a flow file per id, and then send them all to a single InvokeHttp processor and reference a variable in URL of InvokeHttp. Here is a high-level of how it might work...
Lets say starting JSON is:
{ "ids" : [ "1", "2", "3" ] }First use SplitJson processor with a Json Path of $.ids, this will produce 3 flow files where the content of each is 1, 2, and 3 respectively.
Second, use ExtractText processor.. add a user defined property with the name "my.id" and the value of (.*)
That will extract the content of each flow file into an attribute called my.id.
Finally, in InvokeHttp set the Remote URL to http://yourhost/path/${my.id}
When InvokeHttp processors a flow file, it will evaluate Remote URL against the incoming flow file attributes, and replace ${my.id} with the value of that attribute on the particular flow file, which in this case will be 1, 2, or 3.
Created 01-24-2018 08:56 AM
Thank you so much, @Bryan Bende. Your approach absolutely works!