Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Use of clientId parameter in REST API calls

avatar

Just about any operation on https://nifi.apache.org/docs/nifi-docs/rest-api/index.html has a clientId parameter. What is its purpose and benefits? Is it more like maintaining a session? Is there physically a server-side session created for a REST client?

If I don't specify a clientId, do I just keep creating more sessions (as it's auto-generated if not provided)?

1 ACCEPTED SOLUTION

avatar
Rising Star

Requests to NiFi's REST API to change the data flow (mutable requests) require a revision to be included. Since multiple users may be working with the same NiFi instance at the same time, this is used as a simple check to verify the user who submitted the request acknowledges they have the most current version of the data flow before applying their change.

The revision is comprised of two pieces. The first is the version. The version is a one-up number that is updated by NiFi during a mutable request and is included in the response. The next mutable request should include that updated version. This works well until a user wants to submit multiple requests concurrently. To support this case the revision also includes a clientId. If the clientId in the revision of the current request matches the clientId of the last successful mutable request, the version does not need to match.

It is up to the client to manage the revision version and check with

http://{host}:{port}/nifi-api/controller/revision

in order to see if another client has updated the flow.

The clientId can be any string. It's accepted in most endpoints so it could be added to requests in $.ajaxSetup for instance. If the clientId is not specified one will be generated. There is no session, it's simply generates a UUID. You could use any string you may want to represent your client. In the NiFi UI, we GET the flow

http://{host}:{port}/nifi-api/controller/process-groups/root?verbose=true

and use the clientId that it generates for all subsequent requests.

View solution in original post

5 REPLIES 5

avatar
Rising Star

Requests to NiFi's REST API to change the data flow (mutable requests) require a revision to be included. Since multiple users may be working with the same NiFi instance at the same time, this is used as a simple check to verify the user who submitted the request acknowledges they have the most current version of the data flow before applying their change.

The revision is comprised of two pieces. The first is the version. The version is a one-up number that is updated by NiFi during a mutable request and is included in the response. The next mutable request should include that updated version. This works well until a user wants to submit multiple requests concurrently. To support this case the revision also includes a clientId. If the clientId in the revision of the current request matches the clientId of the last successful mutable request, the version does not need to match.

It is up to the client to manage the revision version and check with

http://{host}:{port}/nifi-api/controller/revision

in order to see if another client has updated the flow.

The clientId can be any string. It's accepted in most endpoints so it could be added to requests in $.ajaxSetup for instance. If the clientId is not specified one will be generated. There is no session, it's simply generates a UUID. You could use any string you may want to represent your client. In the NiFi UI, we GET the flow

http://{host}:{port}/nifi-api/controller/process-groups/root?verbose=true

and use the clientId that it generates for all subsequent requests.

avatar
Contributor

Thanks @mgilman for the information. Can you also provide more info on how can we set the ClientID for user group and list the processors for that user group ? ex: hanu is the user group.. i want to set the clientID and list all the processors and the process groups along with the parentIDs. How can we achieve this?

Thanks in advance 🙂

avatar

@mgilman @andrewg @2hanu_valluri 

 

I am also trying to create a NiFi workflow through RestAPI but I have one doubt from where I will get the clientId, I can see when I am creating a processor in request payload there is a revision inside that object clientId is there as parameters. I am not able to understand where I will get that clientId. Any help will be great.
 

avatar
Rising Star

The clientId can be any string that is unique to your client. You can generate one. If one is not specified the endpoints will generate one and return it for you. Please open your web browsers developer tools and watch some of the requests in action.

avatar
New Contributor

Where can i get the client id?