Nifi : Is it possible to create multiple flow file based on attributes ?
Hello,
I receive a json from a HTTP Request. It looks like this :
{
"accessToken" : "token",
"expiresIn" : "12600",
"refreshToken" : "token",
"tokenType" : "Bearer",
"usagePointsId" : "22516914714270, 22516914714270, 22516914714270"
}
I have the usagePointsId key containing a string with multiple values.
I will need each values to include them in different API calls.
I would therefore like to be able to separate the string at the comma level to extract each value.
Then the idea is to create a new unique flow file for each value. This value would be associated with a "usagePointId" attribute which would be used in my API calls. Also, the others json key would be added as Attributes for each flow files
I don't know if it's possible to create multiple differents flow file based on a split attributes.
I tried to use the ExecuteScript (with ECMASCRIPT) to split the string and create Flow Files with something like this :
flowFile = session.get()
if (!flowFile) return
usagePointsId = flowFile.getAttribute('usagePointsId')
splitStr = usagePointsId.split(",");
let attrs = []
for (let i = 0; i < spltStr.length, i+) {
newFlowFile = session.create()
newFlowFile = session.write(newFlowFile, splitStr[i] )
session.transfer(newFlowFile, REL_SUCCESS)
}
Someone could help me with that kind of issue ?
Thanks

