Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

issue merging content in nifi

Solved Go to solution
Highlighted

issue merging content in nifi

Rising Star

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

Accepted Solutions
Highlighted

Re: issue merging content in nifi

Master Guru

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
Highlighted

Re: issue merging content in nifi

Master Guru

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

Highlighted

Re: issue merging content in nifi

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 .

Highlighted

Re: issue merging content in nifi

Rising Star

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

Highlighted

Re: issue merging content in nifi

Rising Star

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

Re: issue merging content in nifi

Master Guru

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

Don't have an account?
Coming from Hortonworks? Activate your account here