Support Questions
Find answers, ask questions, and share your expertise

Provide nifi variable from nifi rest API

Solved Go to solution

Provide nifi variable from nifi rest API

Explorer

Is there any way where we can provide nifi processor group variables when executing the process group from rest api as parameter

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Provide nifi variable from nifi rest API

Master Guru

@aman mittal

-

What the actual curl command will look like depends on whether your NiFi target is secured or not and how it has been secured. I am not completely clear on what you mean by "executing the process group".

-

Here is an example curl command that can be used to create or update a key/value variable on an existing process group. This example assumes the NiFi has been secured and authorization is via LDAP.

-

# Obtain a user authentication token:

token=$(curl -k 'https://<hostname>:<port>/nifi-api/access/token'  --data 'username=<username>&password=<password>’)

-

#Get current process group variable-registry details:

curl -k 'https://<hostname>:<port>/nifi-api/process-groups/<process group uuid>/variable-registry' -H "Authorization: Bearer $token"

-

#create or update a variable on a specific process group:

curl -k 'https://<hostname>:<port>/nifi-api/process-groups/<process group uuid>/variable-registry/update-requests' -H "Authorization: Bearer $token" -H 'Content-Type: application/json' --data-binary '{"processGroupRevision":{"clientId":"<client id from above response>","version":2},"variableRegistry":{"processGroupId":"<process group uuid>","variables":[{"variable":{"name":"new-pg-var","value":"testing1234"}}]}}' --compressed

-

Note: If you Target Nifi is unsecured you will not need to worry about authentication or authorization. So above command would not require "-k" or "-H "Authorization: Bearer $token". The URL in that case would also be http instead of https.

-

Thank you,

Matt

-

If you found this Answer addressed your original question, please take a moment to login and click "Accept" below the answer.

View solution in original post

3 REPLIES 3
Highlighted

Re: Provide nifi variable from nifi rest API

Master Guru

@aman mittal

-

What the actual curl command will look like depends on whether your NiFi target is secured or not and how it has been secured. I am not completely clear on what you mean by "executing the process group".

-

Here is an example curl command that can be used to create or update a key/value variable on an existing process group. This example assumes the NiFi has been secured and authorization is via LDAP.

-

# Obtain a user authentication token:

token=$(curl -k 'https://<hostname>:<port>/nifi-api/access/token'  --data 'username=<username>&password=<password>’)

-

#Get current process group variable-registry details:

curl -k 'https://<hostname>:<port>/nifi-api/process-groups/<process group uuid>/variable-registry' -H "Authorization: Bearer $token"

-

#create or update a variable on a specific process group:

curl -k 'https://<hostname>:<port>/nifi-api/process-groups/<process group uuid>/variable-registry/update-requests' -H "Authorization: Bearer $token" -H 'Content-Type: application/json' --data-binary '{"processGroupRevision":{"clientId":"<client id from above response>","version":2},"variableRegistry":{"processGroupId":"<process group uuid>","variables":[{"variable":{"name":"new-pg-var","value":"testing1234"}}]}}' --compressed

-

Note: If you Target Nifi is unsecured you will not need to worry about authentication or authorization. So above command would not require "-k" or "-H "Authorization: Bearer $token". The URL in that case would also be http instead of https.

-

Thank you,

Matt

-

If you found this Answer addressed your original question, please take a moment to login and click "Accept" below the answer.

View solution in original post

Highlighted

Re: Provide nifi variable from nifi rest API

Explorer

@Matt Clarke above command gives the following error .

The specified resource could not be found.curl: (6) Could not resolve host: Content-Type; Name or service not known

Highlighted

Re: Provide nifi variable from nifi rest API

Explorer

It works .. Thanks you