From the course: Java: Automated API Testing with REST Assured

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Making a DELETE request

Making a DELETE request - Java Tutorial

From the course: Java: Automated API Testing with REST Assured

Start my 1-month free trial

Making a DELETE request

- [Instructor] Delete requests allow you to remove a resource from a system. We can delete a product by using this endpoint. Let's create a new test, and we'll call this one deleteProduct. Let's go ahead and define our endpoint. Let's also create a body. Inside of the body, we'll need to specify the ID of the product that we'd like to delete. So let's go to the database to determine what's the ID for the water bottle. So I'll say select from the products table where the name equals "Water Bottle". And we can see that the ID is 19. Perfect. So let's go ahead and add that ID to the body. We can specify ID, and then the value, which is 19. Great. Now we're ready to make our requests. So we're going to store that inside of the response. And we'll say, given this body, when we call the delete method on this endpoint, then we'll get a response. And we can print this response out by saying response.log.body. Great. Let's…

Contents