How to pass parameter in request body of restassured api in JAVA?

In below example, if i run this it is taking z as string, not as parameter, 

String z=   "1234";
        try {
            RestAssured.baseURI = "";
            String requestBody ="{"CompanyID":z"
                    + ""
                    + ""
                    + "}";`

How to pass parameter Z in company ID, right now it is taking company id as z, i want it should take value of z.


You need to be careful with escaping the quotation marks when using strings directly. You can try using the code below.

String z = ""1234"";

String requestBody: "{"name":"+z+"}";

Leave a Reply

Your email address will not be published. Required fields are marked *