Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Highlighted
Mauritz_SA
Contributor III

Qrs get all users with a specific custom property

Hi all

I have custom property which I can assign to a user called AvailableStreams. This is used to determine which users have access to which streams with a generic security rule. How can I get all the users who have not been removed externally with a certain AvailableStreams custom property value using an API?

I am able to get a list of users who are not removed externally using the following call:

https://<server name>:4242/qrs/user/full?Xrfkey=0000000000000000&filter=removedExternally eq false

What do I need to add to the call to find all users which have a 'Client1' value in AvailableStreams?

It seems like it will be a customProperties filter, but I have no idea what the syntax should be.

https://help.qlik.com/en-US/sense-developer/February2019/APIs/repositoryserviceapi/index.html?page=1...

PS: a user can have more than one AvailableStreams custom property value.

I would appreciate any help.

Thanks,

Mauritz

UPDATE:

I got a partial solution just after posting the question.

https://<server name>:4242/qrs/user/full?Xrfkey=0000000000000000&filter=removedExternally eq false and customProperties.value eq 'Client1'.

However, with this I do not specify which Custom Property has to have a value equal to Client1. Is there a way that I can specify that the AvailableStreams custom property should be equal to 'Client1'? I am just scared that in future I will dig a hole for myself if I want to manage other privileges using custom properties which might have the same values (i.e. having 'Client1' as a value for another custom property in future).

Labels (1)
1 Solution

Accepted Solutions
Employee
Employee

Re: Qrs get all users with a specific custom property

You can always call things like so: /qrs/user/full?filter=(@foo eq 'bar'). Is that not working?
4 Replies
Employee
Employee

Re: Qrs get all users with a specific custom property

You can always call things like so: /qrs/user/full?filter=(@foo eq 'bar'). Is that not working?
Mauritz_SA
Contributor III

Re: Qrs get all users with a specific custom property

Hi @LeviTurner 

Thanks, that's exactly what I wanted! I will mark it as a solution. Can you maybe give me the syntax for filtering on user attributes (for example and attribute called SomeAttribute) as well?

For example:

/qrs/user/full?filter= removedExternally eq false and (@AvailableStreams  eq 'Client1' or SomeAttribute eq 'Client1')

After your previous message I assumed that custom properties have an @ before them and that attributes would not have anything (like in security rules), but I get a "Cannot convert the constant value: SomeAttribute" error in Postman.

Maybe I am searching incorrectly, but I was not able to find any examples of this. Is there a place which explains the syntax for using different Qlik 'elements' in API calls?

Regards,

Mauritz

Update:

It seems like /qrs/user/full?filter= removedExternally eq false and (@AvailableStreams  eq 'Client1' or attributes.attributeType eq 'SomeAttribute' and attributes.attributeValue eq 'Client1') works. If this way of doing it is correct, how does it know that the attributeType and attributeValue refer to the same attribute and need to be considered together? For example, would this call not also return a user with a SomeAttribute value of 'Client2' and a SomeOtherAttribute value of 'Client1'? Or are the attributeType and attributeValue conditions considered as a pair? The reason why I am asking is because qrs/user/full?filter= removedExternally eq false and (@AvailableStreams  eq 'Client1' or attributes.attributeValue eq 'Client1') also works and I just want to make sure that I cover all my bases.

erisman20
New Contributor III

Re: Qrs get all users with a specific custom property

@Mauritz_SA

 

Did you find the answer to your last question?

 

I am wanting to filter the response based on some attributes, but dont know how to "group" the filters together.

 

/qrs/user/full?filter=attributes.attributeValue eq 'value1' would work, except if another attribute also had a value of value1, then is would cause unexpected matches

Mauritz_SA
Contributor III

Re: Qrs get all users with a specific custom property

Hi there

It seems as if the attributes.attributeType and attributes.attributeValue are considered as a pair. So you would first specify which attribute (attributes.attributeType) and then filter on a value (attributes.attributeValue). A really nice way of getting the syntax (I stumbled upon it) is to actually build your filter in the users screen in the QMC and then inspect the POST that is made. In Chrome, do the following with the QMC Users page open:

  • Customise and control Google Chrome (top right)
  • More Tools -> Developer Tools
  • Click on Network
  • Set up your filter in the QMC and then make the Search call

The syntax will then be displayed in the Headers pane on the right. Below is an example:

Get parameters.PNG

I hope this helps.

Regards,

Mauritz