Member since
03-21-2018
13
Posts
1
Kudos Received
1
Solution
My Accepted Solutions
Title | Views | Posted |
---|---|---|
7126 | 03-31-2018 05:26 PM |
04-16-2019
04:31 AM
@Marcos Da Silva , we are having the same problem and could you please elaborate on the UDF you are talking about and if possible give the code snippet.
... View more
04-16-2019
04:31 AM
@Marcos Da Silva , we are having the same problem and could you please elaborate on the UDF you are talking about and if possible give the code snippet.
... View more
06-07-2018
05:34 PM
I have added Accept and Authorization in UpdateAttribute processor before InovkeHTTP processor and in the Attributes to Send property (in InovkeHTTP) - I have used .*
... View more
06-04-2018
02:18 PM
@Felix Albani Thank you very much. that worked perfectly. I have one more question. What if I have one more header such as -H "Authorization: Bearer 27ffdfada34982-1123qwdq2" . How do I send it ? Should I be adding one more property and set the name as 'Authorization and Value as Bearer 27ffdfada34982-1123qwdq2 ? or Can I specify more than one attribute in AttributestoSend in InvokeHTTP processor ? If yes, should they be seperated by comma or space or something else ?
... View more
06-01-2018
04:39 PM
I have curl command as below. curl -s -XPOST -H "Accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -d 'username=usco&password=asdl2342&client_id=dwer234324-2sd2-32dwq&scope=read' 'https://rest.abc.com/security' I am trying to replicate this in Nifi. I am trying to figure out how and where the above options to be provided in InvokeHTTP processor. I have gone through the articles and some mentioned I have to define it in body of flow file. But I couldn't understand what exactly goes into body and what goes into extra attributes (if I need to add) in InvokeHTTP processsor.
... View more
Labels:
- Labels:
-
Apache NiFi
03-31-2018
05:26 PM
1 Kudo
I am able to resolve this. var flowFile = session.get();
if (flowFile != null) {
var StreamCallback = Java.type("org.apache.nifi.processor.io.StreamCallback")
var IOUtils = Java.type("org.apache.commons.io.IOUtils")
var StandardCharsets = Java.type("java.nio.charset.StandardCharsets")
var JString = Java.type("java.lang.String")
var TokenAttr = flowFile.getAttribute('token_value')
var JsonTokenAttr = JSON.parse(TokenAttr) ; flowFile = session.write(flowFile,
new StreamCallback(function(inputStream, outputStream) {
var text = IOUtils.toString(inputStream, StandardCharsets.UTF_8)
var obj = JSON.parse(text)
var accounts = obj['customer-accounts'];
var convertedAccounts = accounts.map(function(account, index) {
account['account_number'] = JsonTokenAttr.Tokens[index];return account;
});
var newObj = {'customer-accounts' : convertedAccounts }
var builder = new JString()
outputStream.write(JSON.stringify(newObj, null, '\t').getBytes(StandardCharsets.UTF_8))
})) session.transfer(flowFile, REL_SUCCESS)
}
... View more
03-29-2018
03:34 AM
I am trying to write and execute a Java script in Nifi. Below is all I have defined in the body of Execute script processor. token_value is an attribute and the value for it is - {
"Tokens": [
"12345acdb4567",
"98765acdb1111"
]
} Flow File Content is - { "customer-accounts": [ { "company_identifier": "074", "product_code": "CCD", "account_number": "222222222222", "relationship_code": "JOF", "primary_ownership_indicator": "Y" }, { "company_identifier": "674", "product_code": "CCD", "account_number": "111111111111", "relationship_code": "EOD", "primary_ownership_indicator": "N" } ] } Script I am using is as below. I am not familiar with JavaScript. Trying to get this to work. ScriptBody : var flowFile = session.get() ; if (flowFile != null) {
var TokenAttr = flowFile.getAttribute('token_value') ;
} function convert(flowFile, TokenAttr) {
let accounts = flowFile['customer-accounts'];
let convertedAccounts = accounts.map((account, index) => {
account['account_number'] = TokenAttr.Tokens[index];
return account;
});
return {
'customer-accounts' : convertedAccounts
}
} flowFile = session.write(flowFile,console.log(JSON.stringify(convert(flowFile,TokenAttr)))) session.transfer(flowFile, REL_SUCCESS) your help will be appreciated. Thanks in advance.
... View more
Labels:
- Labels:
-
Apache NiFi