Member since
01-16-2022
2
Posts
0
Kudos Received
0
Solutions
01-17-2022
07:49 AM
Hello All, I am trying to access the NiFi bulletin-board through NiFi API with InvokeHTTP process in order to consume the failure message. Referencing these curl command of this post: Creating NiFi Template via Rest API I am at the V1.15 with single-user login mode. My current attempt is: 1. User GenerateFlowFile to simulate the content for API /access/token. {"Custom Text" : "username=${username}&password=${password}"} 2. Use InvokeHTTP to request the access token. HTTP Method POST Remote URL https://localhost:8443/nifi-api/access/token Content Type x-www-form-urlencoded This will response an access token which will be sent within the header. 3. Use InvokeHTTP to request the bulletin-board. HTTP Method GET Remote URL https://localhost:8443/nifi-api/bulletin-board Authentication Bearer ${access_token} This will response the bulletin-board I need. However In my current approach, the password will appear in the flowfile content as plain-text witch doesn't make it a proper approach. Is there a secure way to obtain an access token (i.e. encrypted password) for latter connection? Am I not understanding the NiFi RestAPI right ? Is there a better approach to request from the NiFi API through NiFi itself ? Thank you all in advanced.
... View more
Labels:
- Labels:
-
Apache NiFi
01-17-2022
07:08 AM
Hello All, I am trying to execute a SQL query fetched from a file, and bind parameters using the flowfile attributes. The file looks like the following with the dollar sign specifying desired parameters like NiFi EL. And the flowfile attributes are value ingested from other sources. flowfile content (fetched from sqlquery.txt) SELECT id FROM users WHERE name = ${target_name} AND gender = ${target_gender}; flowfile attributes target_name 'Tom' target_gender 'male' And what I am trying to attempt is to execute the SQL: SELECT id FROM users WHERE name = 'Tom' AND gender = 'male'; My current approach is: 1. Initialize parameters from other sources and store them in the flowfile attributes. 2. Use FetchFile to get the sql query from the file and store it in the flowfile content. 3. Use ReplaceText to replace literal ${target_name} with the string 'Tom'. 4. Use ReplaceText to replace literal ${target_gender} with the string 'male'. 5. ExecuteSQL It works, but it doesn't seems right when the number of parameters or number of SQL grows. I'll have to maintain lots of ReplaceText processors or one mapping file for each and every SQL using ReplaceTextWithMapping processor. What I am attempting: I am trying to extract the sql query as an attribute to better leverage NiFi expression language. 1. Initialize parameters from other sources and store them in the flowfile attributes. 2. Use FetchFile to get the sql query from the file and store it in the flowfile content. 3. Use ExtractText to extract the sql query sqlquery SELECT id FROM users WHERE name = ${target_name} AND gender = ${target_gender}; 4. ExecuteSQL with the property: SQL select query ${sqlquery} However it execute: SELECT id FROM users WHERE name = ${target_name} AND gender = ${target_gender}; instead of what I am attempting: SELECT id FROM users WHERE name = 'Tom' AND gender = 'male'; Note: I have read the related posts I can find, but none of them really resolve my problem. How can I use variable on query of executeSQL processor on apache NiFi? NiFi Processor to Dynamically Create SQL Query From FlowFile or JSon ExecuteSQL dynamic query.. Is there a way to bind variables when using ExecuteSQL with sql query stored in attribute or content? Or is there a better way to better resolve this use case? Thank you all in advanced !
... View more
Labels:
- Labels:
-
Apache NiFi