Created 03-09-2016 11:39 AM
Hi,
I'm having trouble manipulating flow file content in nifi : i have a flow file which contains a json. I use one of the field of this json to make a http request, up to this point everything works fine. I would like to merge the answer of this request with my original json. The merge content processor doesn't seem appropriate so i'm kinda stuck.
Thank you in advance.
Created 03-09-2016 12:42 PM
I am assuming you are using the InvokeHTTP processor and that you want to use one of the new attributes created on your FlowFile in response to the request for adding to the content of the same Flowfile. You will want to make sure you have the "Put Response Body in Attribute" property configured in the InvokeHTTP processor. You can then use the ReplaceText processor with an Evaluation Mode of Entire text and Replacement Strategy of Append. This will allow you to write a NiFi Expression Language statement that uses the attribute you specified for the response body containing the return and append it to your original json content.
Created 03-09-2016 12:42 PM
I am assuming you are using the InvokeHTTP processor and that you want to use one of the new attributes created on your FlowFile in response to the request for adding to the content of the same Flowfile. You will want to make sure you have the "Put Response Body in Attribute" property configured in the InvokeHTTP processor. You can then use the ReplaceText processor with an Evaluation Mode of Entire text and Replacement Strategy of Append. This will allow you to write a NiFi Expression Language statement that uses the attribute you specified for the response body containing the return and append it to your original json content.
Created 06-20-2017 05:00 AM
Hi,
Can i know how you will write Nifi expression language for 5 fields of json that values coming from another processor.Suppose i have 40 fields in json and 25 having values but 15 fields does not have values/empty fields to it. But i will get the values for 15 fields from another processor and i want to append the values to the 15 empty fields of current json content. Please can you tell me the procedure to do it.
sample json file { "index": 1,
"index_start_at": 56,
"integer": 31,
"float": 11.8891,
"name": "Kyle",
"surname": "Ritchie",
"fullname": "Maria Kelley",
"email": "",
"bool": "" },
where email and bool fields are emptry/null , i want to add values from another processor.
How we achive it ..any steps and screenshots would be great .
Created 03-09-2016 12:45 PM
a bit more information : to make my http request, i used routeOnAttribute --> InvokeHttp which works fine
Created 03-09-2016 02:45 PM
Thank you very much. Just to complete a bit your answer for those as new to nifi as i am :
- the invokeHttp processor must send the "original" to replaceText
- assuming the "Put Response Body in Attribute" property has been set to "Plouf"; the "Replacement Value" property in replaceText must be set to "${Plouf}"
Created 03-15-2016 12:05 PM
@Lubin Lemarchand you are correct. Thank you for filling in the details.