878 views

Rest API multiple filters

Jump to solution

Hi,

This is a very basic question regarding the REST API.

How do I use multiple filters to retreive record from the ems API?

For example, I have the following GET request:

https://[host]/rest/[tenant-id]/ems/ServiceDefinition?layout=Id,DisplayLabel,Category.DisplayLabel&filter=DisplayLabel='Business Support'&filter=Category.DisplayLabel='Credit'

I want to retreive all the Service Definitions where the DisplayLabel is 'Business Support' and the DisplayLabel of the Category is 'Credit'.

I have searched through the documentation and have not found an example of this, it is always one filter. The previous request only considers the first filter.

 

Best regards,

Tomas Azevedo

0 Likes
1 Solution

Accepted Solutions
Micro Focus Expert
Micro Focus Expert

Tomas,

You can only have one filter attribute. The combined filter needs to be inside the attribute.

The query below should work for you

https://[host]/rest/[tenant-id]/ems/ServiceDefinition?layout=Id,DisplayLabel,Category.DisplayLabel&filter=DisplayLabel='Business Support' and Category.DisplayLabel='Credit'

 

A slightly different syntax is to use "startwith", rather than using the equal operator, this will perform the filter on the beginning of the string.

 

https://[host]/rest/[tenant-id]/ems/ServiceDefinition?layout=Id,DisplayLabel,Category.DisplayLabel&filter=DisplayLabel startswith ('Business Support') and Category.DisplayLabel startswith ('Credit')

 

Best regards,

Brindusa

View solution in original post

2 Replies
Micro Focus Expert
Micro Focus Expert

Tomas,

You can only have one filter attribute. The combined filter needs to be inside the attribute.

The query below should work for you

https://[host]/rest/[tenant-id]/ems/ServiceDefinition?layout=Id,DisplayLabel,Category.DisplayLabel&filter=DisplayLabel='Business Support' and Category.DisplayLabel='Credit'

 

A slightly different syntax is to use "startwith", rather than using the equal operator, this will perform the filter on the beginning of the string.

 

https://[host]/rest/[tenant-id]/ems/ServiceDefinition?layout=Id,DisplayLabel,Category.DisplayLabel&filter=DisplayLabel startswith ('Business Support') and Category.DisplayLabel startswith ('Credit')

 

Best regards,

Brindusa

View solution in original post

That was it @Brindusa Kevorkian , thank you very much.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.