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.

Solution: Use requests to complete the lifecycle of a resource

Solution: Use requests to complete the lifecycle of a resource - Java Tutorial

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

Start my 1-month free trial

Solution: Use requests to complete the lifecycle of a resource

(upbeat music) - [Instructor] Great job. Let's walk through the solution of creating, updating, viewing, and deleting a product using API requests. To create a new product, we needed to make an API request to the create endpoint. We must give it the data of the product we'd like to create. So our body contains the name, the description, the price, and the category ID. Next, we make the request via the post method. And remember, this is the API method to create new resources. Now that our product is created, to update it, we use the update endpoint. We provide a body specifying the ID, which in my case, is 26. Yours could be different, just depends on what was stored in your database. And I also specify the price field with an updated value of six. I didn't include any other fields since they will remain the same. If you included all of the fields, that's okay. I just wanted to show you that those are not required.…

Contents