Search code examples
javarest-assuredlinkedhashmap

When using Rest Assured, if I send a post request to summit data to server, how can I write "ABC":["XYZ"] this value in LinkedHashmap


Request body is:-

{
"request":
{
  "body": 
{
    "ABC":["XYZ"],
    "PASSWORD": "password"
  }
}

MY CODE:-

I am getting error in response because the ABC value is going in string format

    Map body = new LinkedHashMap(6);
    body.put("ABC","XYZ");
    body.put("PASSWORD","password");

what is the correct way to write this request body using LinkedHashMap in restAssured

"ABC":["XYZ"],


Solution

  • You just need change it to List<String>

    body.put("ABC", Arrays.asList("XYZ"));