检查数组是否在Cumulocity REST API中包含值查询

问题描述

我有一个类型为“ 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运算符。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...