Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

Once I split a JSON Array, how to use each spplited JSON object to call an HTTP GET response ?

avatar
New Member

I'm issuing the following URL by using a GetHTTP processor named "States", whose URL property - ${DOMAIN} is omitted for issues of brevity - is

http://${DOMAIN}/api/states

which gives me the following results

[
    {
        id: 1,
        name: "Alabama"
    },
    {
        id: 2,
        name: "California"
    }
...
]

Then I split the array by using a SplitJson processor "Split by state", whose JsonPathExpression property is

$.*

so that I can fetch each object of the array shown above. Next, I use a AttributesToJSON to map the property id to a state flowfile-attribute, as below

Destination - flowfile-attribute

state - $.id

Now, for each spplited JSON object, I want to issue a new GET HTTP called "Municipalities by state" in the form of http://${DOMAIN}/api/states/${state}/municipalities. However, NiFi doesn't allow me "connect" the AttibutesToJson to an GetHttp processor. So What should I do to enable the GetHttp processor "Municipalities by state" ?

1 ACCEPTED SOLUTION

avatar
Master Guru
@Ferrero Rocher

Use InvokeHTTP processor which allows incoming connections instead of GetHTTP processor

Flow:-

1.GetHTTP
2.SplitJson //split array $.*
3.EvaluateJsonPath //to extract id value and keep as state attribute
4.InvokeHTTP //http://${DOMAIN}/api/states/${state}/municipalities

View solution in original post

1 REPLY 1

avatar
Master Guru
@Ferrero Rocher

Use InvokeHTTP processor which allows incoming connections instead of GetHTTP processor

Flow:-

1.GetHTTP
2.SplitJson //split array $.*
3.EvaluateJsonPath //to extract id value and keep as state attribute
4.InvokeHTTP //http://${DOMAIN}/api/states/${state}/municipalities