Skip to main content

PUT Request using REST Assured

The HTTP PUT request method creates a new resource or replaces a representation of the target resource with the request payload. 

If the Request-URI does not point to an existing resource, and that URI is capable of being defined as a new resource by the requesting user agent, the origin server can create the resource with that URI.

If a new resource is created, the origin server MUST inform the user agent via the 201 (Created) response. If an existing resource is modified, either the 200 (OK) or 204 (No Content) response codes SHOULD be sent to indicate successful completion of the request.

public class ReqRes 
	public static String id = "2";

	public void setup()
		RestAssured.baseURI = "";
		RestAssured.basePath = "api";

	/*Put request example*/
	public void putExample()
		Response res = 
					.body("{\n" + 
							"    \"name\": \"Tarun Goswami1\",\n" + 
							"    \"job\": \"QA\"\n" + 

In above code if the request is successful it will return 200.

Video Tutorial


Elix is a premium wordpress theme for portfolio, freelancer, design agencies and a wide range of other design institutions.