Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Mauritz_SA
Partner - Specialist
Partner - Specialist

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
Levi_Turner
Employee
Employee

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

View solution in original post

8 Replies
Levi_Turner
Employee
Employee

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

Hi @Levi_Turner 

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
Contributor III
Contributor III

@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
Partner - Specialist
Partner - Specialist
Author

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

ryanplkam
Partner - Contributor III
Partner - Contributor III

Great tip!

babitaku
Contributor III
Contributor III

Hi @Levi_Turner ,

What filter we can use to /qrs/user endpoint to get the list of users with blank Custom Property?

Levi_Turner
Employee
Employee

@babitaku : I am not aware of filtering on null. So you'd want to get all possible values then arrange a filter with them. Example: GET /qrs/user/full?filter=@Country ne 'USA' and @Country ne 'Finland'

cjgorrin
Contributor III
Contributor III

This post really helped me with a query I needed to run over Qlik Sense users. I wanted to obtain all users with a specific value in a user attribute (the ones that you cannot edit in the QMC).

In the end, this filter did it for me:

attributes.attributeType eq 'MyAttrName' and attributes.attributeValue eq 'MyAttrVal'

 

Thank you @Mauritz_SA. Unfortunately, the filtering feature of the QRS API is very poorly documented.