- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
NiFi: split response json for a subsequent http request
- Labels:
-
Apache NiFi
Created ‎11-29-2017 04:19 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need to read an API where my first call will return a JSON with objectIDs in this form:
{
- objectIdFieldName: "ID",
- objectIds: [
- 64916,
- 67266,
- 67237,
- 64511,
- ....
- ..]
}
I need to use the objectIds above to send requests for each of these IDs to the API that will return the data that i need.
I was thinking a flow:
GetHTTP (get response JSON) --> EvaluateJSONpath (parse only objectIds field: $.objectIds) --> ? --> InvokeHTTP (new query per ID)
My problem comes after that as what i get is a sort of objectIds array in the form of:
[64916, 67266, 67237, 64511,...,]
How to i manage to split/parse each ID from this array in a flowfile attribute so that i can send it along with other data/headers to the InvokeHTTP processor?
I thought to use SplitJson processor but i am having difficulties to understand its usage in this case.
Any help much appreciated!
Created on ‎11-29-2017 04:45 PM - edited ‎08-17-2019 08:58 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use SplitJson Processor with the following configs:-
Input Json:-
{ "objectIdFieldName": "ID", "objectIds": [ 64916, 67266, 67237, 64511] }
Output:-
will be different flowfiles per objectId
64916
67266
67237
64511
Use Extract Text processor:-
extract the content of the flowfile by adding new property
id as
(.*)
Right now you will have id attribute added to the flowfile
then you can use the id attribute when you are doing InvokeHTTP processor
Flow:-
GetHTTP (get response JSON) --> SplitJson -->ExtractText--> InvokeHTTP (new query per ID)
Created on ‎11-29-2017 04:45 PM - edited ‎08-17-2019 08:58 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use SplitJson Processor with the following configs:-
Input Json:-
{ "objectIdFieldName": "ID", "objectIds": [ 64916, 67266, 67237, 64511] }
Output:-
will be different flowfiles per objectId
64916
67266
67237
64511
Use Extract Text processor:-
extract the content of the flowfile by adding new property
id as
(.*)
Right now you will have id attribute added to the flowfile
then you can use the id attribute when you are doing InvokeHTTP processor
Flow:-
GetHTTP (get response JSON) --> SplitJson -->ExtractText--> InvokeHTTP (new query per ID)
