Search code examples
jsonregexapache-nifi

Json field match in Apache NiFi


I have a json coming as response from an InvokeHTTP like this:

{
   "id": "1234567890",
   "status": "completed",
   "others": "abc",
   "field": "1"
}

I would like to use a processor (maybe RouteOnAttribute??) that checks if the status of the response is completed and in case of un-match, it goes back to the invokeHttp to check status again.

I tried this thing: EvaluateJsonPath(to extract id from json) -> InvokeHTTP(to get status) -> RouteOnAttribute(to check status if completed)

  • -> match goes to a funnel
  • -> unmatch goes to EvaluateJsonPath again (to create a loop)

For the InvokeHTTP I need the original json file since I have to get the request id.

I used Route to property name with the following attribute: status - ${status:equals('completed')}

unfortunately, I always receive an un-match even if the status is completed.

Where is the issue?


Solution

  • I have built dummy flow, to check your case, see no issues. Here is the flow: enter image description here Key points here:

    1. In top EvaluateJsonPath i use flowfile-attribute as destination and add new property - status enter image description here
    2. In RouteOnAttribute i check value of status enter image description here
    3. In bottom EvaluateJsonPath i extract id, and as destination i use flowfile-content enter image description here