restapache-nifiwebservices-client

How to invoke remote rest service in InvokeHttp nifi processor?


Is there any way to invoke remote rest service via invokeHttp nifi processor and change its url permamently. In my case I need to pass 2 paramters to get request and I need to change them time after time. Is there any nifi processor which I can use for writing my parameters as attributes in it and connect it with invokehttp consequently? My parameters in invokehttp remote url will change, is there any processor or maybe several processors which can help me make this task?


Solution

  • Bryan answered this with a comment in response to your previous question.

    To provide dynamic values that are used as parameters in the request URI, simply reference attributes on the incoming flowfile using the Apache NiFi Expression Language. Many processors can provide those attributes, but UpdateAttribute is probably where you want to start. For example, if that processor sets two attributes (username and threshold), you would have a series of flowfiles like this:

    1. Flowfile 1 | username 'andy' | threshold '27'
    2. Flowfile 2 | username 'bryan' | threshold '12'
    3. Flowfile 3 | username 'sally' | threshold '22'

    Your InvokeHTTP processor would be configured with a URI like https://my.remote.service:8080/incoming?username=${username}&threshold=${threshold}. Thus, as the flowfiles pass through the processor, your outgoing HTTP requests would be:

    1. https://my.remote.service:8080/incoming?username=andy&threshold=27
    2. https://my.remote.service:8080/incoming?username=bryan&threshold=12
    3. https://my.remote.service:8080/incoming?username=sally&threshold=22