Support Questions

Find answers, ask questions, and share your expertise

Who agreed with this solution

avatar
Master Guru

@Arsalan Siddiqi

One way to do this is extract all the content of the json file as attributes associated with the flowfile.

Then once you make invoke http extract the results of invokehttp to attributes again.

By following this process all the contents will be associated as attributes of the flowfile i.e the attributes associated with the flowfile includes the content of your json file, results of your invoke http processors because we are extracting every content and keeping them as attributes to the flowfile.

In final use AttributesToJson processor and keep all the attributes you need in that, this processor will result a json message and store that to mongodb.

Flow:-

1.EvaluateJsonProcessor //extract the content to flowfile attribute
2.invokehttp 
3.EvaluateJsonProcessor//extract the result of invoke http to flowfile attribute
4.AttributesToJSON //give all the list of attributes you need. so that this processor prepares new json message.

Example:-

Input Json file:-

{
"id": 1,
"name": "HCC",
"age": 20
}

extract all the content i.e id,name,age using Evaluatejsonpath change Destination property to flowfile-attribute processor, now all the content will be associated as attributes now.

Evaljsonpath configs:-

41501-evaluatejsonpath.png

Then do invokehttp now the result flowfile from invokehttp also will have id,name,age attributes associated with it.

use another evaluatejsonpath(if response from invokehttp is json) and extract the invokehttp results as attributes again.

lets consder invokehttpresult will have

{ "dept": "community"} 

extract dept as attribute.

Right now your flowfile will have id,name,age,dept as attributes to the flowfile.

you can do as many invokehttps as you want after each invoke http extract the content as attribute.

Now you need to prepare a json message use AttribiutestoJSON processor

Change the property

attributes list as

id,name,age,dept

This processor now prepares new json message with all the attributes you listed in the processor.

{ "id": 1, "name": "HCC", "age": 20,"dept": "community"}

Use the json result from Attributestojson processor to store into mongoDB.

AttributesToJSON Configs:-

41502-attributestojson.png

View solution in original post

Who agreed with this solution