Support Questions

Find answers, ask questions, and share your expertise

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

avatar
New Contributor

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