Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Use of clientId parameter in REST API calls

Solved Go to solution

Use of clientId parameter in REST API calls

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

Accepted Solutions
Highlighted

Re: Use of clientId parameter in REST API calls

Contributor

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

4 REPLIES 4
Highlighted

Re: Use of clientId parameter in REST API calls

Contributor

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

Highlighted

Re: Use of clientId parameter in REST API calls

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 :)

Highlighted

Re: Use of clientId parameter in REST API calls

New Contributor

@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.
 
Highlighted

Re: Use of clientId parameter in REST API calls

Contributor

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.

Don't have an account?
Coming from Hortonworks? Activate your account here