0

I want to add payload like this:

{
    "data": [
        {
            "name": "saumy",
            "code": "say1y"
        },
        {
            "name": "saumy",
            "code": "say1y"
        }
    ],
    "dispositionList": "11379"
}

I have successfully able to add

 {
        "name": "saumy",
        "code": "say1y"
    }

but I am not able to get how to add comma separated next array list.

In step definition i have added the first using:

@Then("Uses the token and create Bulk disposition status payload with {string} {string}")
    public void uses_the_token_generated_and_created_bulk_disposition_status_payload_with(String name, String code)
            throws IOException {
        randomName = name + randomNumber;
        datajson = new Data("CODE", "CODE123");
        res = given().spec(requestSpecification()).body(data.addDispositionStatus(randomName, code, listId, datajson))
                .relaxedHTTPSValidation();
    }

What can be added to add the next array list?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
ayush
  • 3
  • 1

1 Answers1

0

You can check the official docs here Rest-Assured: multi-value parameter

Create an arrayList (of objects) and add your objects to it.

Example:

Data data1 = new Data("code", "code123");
Data data2 = new Data("otherCode", "code456"); 

ArrayList payloadData = new ArrayList();
    payloadData.add(data1);
    payloadData.add(data2);


given().body(payloadData).then().statusCode(200);
Maverick
  • 61
  • 1
  • 5