Support Questions

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

issue merging content in nifi

avatar
Expert Contributor

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.

1 ACCEPTED SOLUTION

avatar
Master Mentor

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.

View solution in original post

5 REPLIES 5

avatar
Master Mentor

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.

avatar
Contributor

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 .

avatar
Expert Contributor

a bit more information : to make my http request, i used routeOnAttribute --> InvokeHttp which works fine

avatar
Expert Contributor

@mclark

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}"

avatar
Master Mentor

@Lubin Lemarchand you are correct. Thank you for filling in the details.