From the course: Building RESTful APIs in Laravel

Unlock the full course today

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

POST a new petition

POST a new petition

From the course: Building RESTful APIs in Laravel

Start my 1-month free trial

POST a new petition

- [Instructor] Let's test the store method to make sure that we can create a new petition. Looking at the php artisan route:list output, we can see that the method will be POST, the URI will be api/petitions, and the action is the store method on the petition's controller. If everything works, we will be able to create a brand new petition using Postman increasing the total number of petitions from 50 to 51. We need to create a new request and I will do that by clicking on the New button. I'll call it POST a petition, save it in the ePetitions collection, and I will choose to POST method from the dropdown. The request URL is exactly the same as the one we used in our GET petitions request from the last video so I'll just copy it over. Sending a POST request is slightly more complicated because we have to create the body of the request ourselves. Switch to the Body tab, click raw, and select JSON. To make it easier, we…

Contents