问题描述
我有一个类型为“ ABC”的受管理对象,其片段为“ A”,其子结构如下:
{
"type": "ABC","A": {
"value": ["B","C"]
}
}
如何创建一个过滤器/查询来检查“值”数组中“ A”片段是否包含“ C”?
该查询失败:
{{url}}/inventory/managedobjects?query=$filter=(type+eq+'ABC'+and+A.value+has+‘C‘)
使用
{
"error": "inventory/Invalid Data","message": "Find by filter query Failed : Query '$filter=(type eq 'ABC' and A.value has ‘C‘)' Could not be understood. Please try again.","info": "https://www.cumuLocity.com/guides/reference-guide/#error_reporting"
}
Cumulocity doc关于查询REST API。
解决方案: 使用eq代替has:
{{url}}/inventory/managedobjects?query=$filter=(type+eq+'ABC'+and+A.value+eq+‘C‘)
解决方法
我找不到来源,但以下内容对我来说有预期的效果:
{{url}}/inventory/managedObjects?query=$filter=(type+eq+'ABC'+and+A.value+eq+'C')
因此,基本上,您需要在用例中使用eq运算符。