API filter - Trying to get exact match

api

#1

Hi,

I’m trying to query assets from the Orchestrator, using the $filter option to look for assets with a specific name. However, I can’t manage to get $filter to return an exact match using the eq expression.

The problem occurs when I have assets, where the name of one asset is a substring in the name of the other asset.

For example, I created an asset called foo, and an asset called buffoon. When I query the asset named buffoon, exactly that asset returned, as expected:
GET https://platform.uipath.com/odata/Assets?$filter=Name%20eq%20'buffoon'

{ "@odata.context": "https://platform.uipath.com/odata/$metadata#Assets", "@odata.count": 1, "value": [ { "Name": "buffoon", "CanBeDeleted": true, "ValueScope": "Global", "ValueType": "Text", "Value": "eleven", "StringValue": "eleven", "BoolValue": false, "IntValue": 0, "CredentialUsername": "", "CredentialPassword": "", "Id": 19900, "KeyValueList": [] } ] }

However, when I query for foo, both assets are returned, even though I use eq meaning that the Name should exacly match ‘foo’:
GET https://platform.uipath.com/odata/Assets?$filter=Name%20eq%20'foo'

{ "@odata.context": "https://platform.uipath.com/odata/$metadata#Assets", "@odata.count": 2, "value": [ { "Name": "foo", "CanBeDeleted": true, "ValueScope": "Global", "ValueType": "Text", "Value": "one", "StringValue": "one", "BoolValue": false, "IntValue": 0, "CredentialUsername": "", "CredentialPassword": "", "Id": 19899, "KeyValueList": [] }, { "Name": "buffoon", "CanBeDeleted": true, "ValueScope": "Global", "ValueType": "Text", "Value": "eleven", "StringValue": "eleven", "BoolValue": false, "IntValue": 0, "CredentialUsername": "", "CredentialPassword": "", "Id": 19900, "KeyValueList": [] } ] }

The same happens, even when I use other filter expressions that should for sure give me only the one I’m looking for, for example endswith(Name, 'foo').
GET https://platform.uipath.com/odata/Assets?$filter=endswith(Name%2C%20'foo')

It looks to me like UiPath Orchestrator is changing all OData $filter expressions to substringof OData $filter expressions,

Has anyone encountered the same, and found a solution?

Kind regards,
Peter.


#2

Hi Peter,

If you check in Orchestrator’s interface, the search would return the same 2 results. So it’s as intended in every page except for the Transactions page, when search by Reference it has a search technique “start with”.

But if you have a proposal for this to change and get an exact match when searching, you can post in User Voice - Ideas category(it’s better if you give a use case example for it) and someone from product team will definitely see and respond to you if it can or cannot be implemented.


#3

Hi @ovi,

I don’t want any changes in the Orchestrator user interface. I’m pretty sure the way it works is fine. My problem occurs when using the $filter expression in the API, not when using the Orchestrator interface.

The problem is that the API, which is supposed to be OData version 4.0 standard compliant (at least, that’s the remark that the version 2016.2 API documentation starts with), doesn’t return what I expect it to return, when using the EQ filter operator.

If you translate it to actual code, you would expect the following example to return False:

Dim Name As String = "somepar"
If "somepar" = "someparameter" Then
   Return True
Else
   Return False
End if

However, when I use the Orchestrator OData implementation for the same thing, it returns True for both "somepar" and "someparameter". I wouldn’t expect that to happen.

If I want a filter to get all Names that contain "somepar", I would expect to use the contains (or substringof) function in OData. I guess that’s what the Orchestrator interface is using, if it wants to return all matching results, which is great. But it’s not what I want as a result from the API.

Kind regards,
Peter.


#4

Hi Peter,

True, but Assets, Robots, Processes and Packages don’t support OData. For Assets it’s because how the Value is calculated(according to asset’s Type), for Processes and Packages because of the external MyGet server.

So that’s why you cannot get an exact match.


#5

Hi @ovi,

That’s too bad, but at least it’s clear to me now. I’ll create a client-side filter to get exact matches out of the API response. Thank you for informing me.

Peter.