2

在使用 rest-assured 测试 REST API 时,我有一个非常具体的用例。我想从以下 JSON 响应中检索“@odata.type”的值;

{
 "value": [
            {
                "@odata.type": "#example.type1.",
                ...
             },
             {
                "@odata.type": "#example.type1.",
                ...
             },
            ...
          ]
      }

我尝试了一些类似的东西

get(/path).then().body("value.@odata.type",hasItems("expected_velue"));

但最终得到这个错误

java.lang.IllegalArgumentException: The parameter "null" was used but not defined. Define parameters using the JsonPath.params(...) function
...

我怎样才能逃脱@odata.type,以便将其视为单个属性来检索其值?

提前致谢

4

0 回答 0