- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Explain PUT request in Rest Assured.
A PUT request is used to pass data to the server for the creation or modification of a resource. The difference between POST and PUT is that POST request is not idempotent.
This means invoking the same PUT request numerous times will always yield the same output. But invoking the same POST request numerous times will create a similar resource more than one time.
The status codes for PUT requests are −
- 200 - request is successful along with modification in the Response body.
- 400 - request is unsuccessful.
- 204 - request is successful without content.
Example
Code Implementation
import org.testng.annotations.Test; import static io.restassured.RestAssured.*; import io.restassured.RestAssured; public class NewTest { @Test void test() { //update title in body String b = "{
" + " \"title\": \"Tutorialspoint\"}"; //base URL RestAssured.baseURI = "https://jsonplaceholder.typicode.com"; //update title in body for resource id = 1 given().header("Content-type", "application/json") //adding put method .body(b).when().put("/posts/1").then().log().all() //verify status code as 200 .assertThat().statusCode(200); } }
- Related Articles
- Explain DELETE request in Rest Assured.
- How to get the response time of a request in Rest Assured?
- How to validate the response time of a request in Rest Assured?
- How to pass more than one header in a request in Rest Assured?
- How to update the value of a field in a request using Rest Assured?
- How to pass the request body from an external file in a separate package in Rest Assured?
- What is Rest Assured?
- Validate JSON Schema in Rest Assured.
- What is XmlPath in Rest Assured?
- What is JSON parsing in Rest Assured?
- Explain how to get the size of a JSON array response in Rest Assured.
- How to handle static JSON in Rest Assured?
- How to validate XML response in Rest Assured?
- How to use Assertion in response in Rest Assured?
- How to create a PUT request in Postman?

Advertisements