Search code examples
apache-nifi

NiFi transfering data between processors


I want to create a simple flow. Firstly, I need to take accountIds from REST service and then use received values to create new HTTP request to get token, and then use this token to create some requests with Oauth2.

common_flow

AccountIds flow: accountIds

From InvokeHttp I'll receive some ids in json (REST written in Java and returns List with Integers). 99% chance that there will be only one number. My response looks like: [40]. Now I need to replace square brackets and get this number (using SplitJson). This number I should put to the next getToken as one of the GET param (on a screenshot i hardcode this):

token enter image description here

This will return a token. Token is a text/plain;charset=UTF-8. And then, i want to use InvokeHttp again, add atribute Authorization and add to this attribute Bearer + received token. I do not really understand how to use the received data from processors in the following processors. Can someone explain how to reach it with my flow?


Solution

  • The Rest Api provides you with payload body - in nifi terms a flowfile content, you need to parse that incoming content using an evaluatejson (if payload is json - in most cases) and store it in flow attributes. Then this attributes will be used in the down stream processors.

    Also to pass the Authorization to your InvokeHTTP you need to decalre it in the InvokeHTTP porcesor. The ${access_token} is from the upstream attributes extraction. enter image description here