Support Questions

Find answers, ask questions, and share your expertise

Invoking Nifi rest api in Data Flow

avatar
Visitor

Hello,

In Cloudera Data Flow, how should an InvokeHTTP processor be configured to be able to invoke the underlying nifi's rest api? 

I've tried several (localhost, with and without ssl etc.) options, but the connection is always refused.

Thanks,

Peter

2 REPLIES 2

avatar
Master Mentor

@ptrsz 

Welcome to the community.

The more detail you can provide, the better the community can assist.

  1. Are you trying to use the InvokeHTTP to return from the NiFi rest-api of the same NiFi instance where this NiFi sis running or accessing the rest-api of another NiFi instance?
  2. Is this a NiFi cluster or standalone NiFi instance?
  3. What version of Apache NiFi are you using (rest-api endpoint may differ by version)?
  4. What rest-api endpoint are you trying to use?

Here is an example configuration using a secured Apache NiFi 2 instance to retrieve the NiFi system diagnostics data from the NiFi rest-api of the same Nif where the dataflow is running.

  • Since NiFi is secured, the rest-api endpoint will require authentication and authorization.  The easiest way to set this up is to use a clientAuth certificate keystore for authentication.  So I setup a StandardRestrictedSSLContextService within the NiFi Process Group.MattWho_0-1764785452590.png
  • I then configured my InvokeHTTP processor to use the above SSL Context service and configured the appropriate rest-api endpoint for the system diagnostics (https://<nifi-hostname>:<nifi-port>/nifi-api/system-diagnostics)MattWho_1-1764785580514.png

     

  • Next I need to make sure my clientAuth certificate DN user identity has been authorized for the "view system diagnostics" within the NiFi Policies; otherwise , you will encounter a 401 not authorized response:
    MattWho_2-1764785802621.png

     

  • Now when my invokeHTTP executes I get the json response from that rest-api endpoint with my diagnostic data:MattWho_3-1764785992172.pngMattWho_4-1764786064853.png

     

     

Please help our community grow. If you found any of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "Accept as Solution" on one or more of them that helped.

Thank you,
Matt

avatar
Master Guru

Great info! To add to this, if you start with a ReadyFlow (such as Hello World), it comes with a pre-configured SSL Context controller service you can use in Matt's procedure above without having to configure it yourself.