2

I have a very specific use case while using rest-assured for testing REST API. I would like to retrieve a value of '@odata.type' from following JSON response;

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

I tried something likle

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

but end up getting this error

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

How can I escape @odata.type so that it will be treated as a single attribute to retrieve its value?

Thanks in advance

  • I tried get(/path).then().body("value.\u0040odata\u002Etype",hasItems("expected_velue")); unicode for @ - \u0040 unicode for . - \u002E but I got this error: JSON path value.@odata.type doesn't match. Expected: (a collection containing "expected_velue") Actual: [] – Amarjit Thouna Nov 29 '17 at 09:06

0 Answers0