After reading this article you will know:
- What different Http methods there are
- What the methods are used for
- When to pick which method
Http methods on web pages are used for handling requests between your web browser (client side) and the Betty Blocks web server. The chosen method on a single web page either defines to retrieve data or to create new data.
In the web module, the GET en POST http methods are used the most. The other http methods can be used used for the Betty Blocks API.
The GET method retrieves whatever information is identified by the URL. A GET request only receives data. In most cases, the received data is a webpage.
The POST method is used to submit data to the specified resource. When you're using the API, you'll use POST's to create new records. When you're creating a front-end form page, the form page will be a GET endpoint, sending all data to a POST endpoint on which you execute an action.
The PUT method is used for updating data via the Betty Blocks API
The DELETE method is used for deleting data via the Betty Blocks API
The HEAD method asks for a response identical to that of a GET request, but without the response body. With this, you could check wether a resource has been updated (assuming the resource has put the updates)
Options is more a documentation type of request method where you can request what request methods are supported by that endpoint. But most API's don't even implement this feature.
The GET and POST request method are the most used request methods, if you're nog using any webservice, these will most probably be the only request methods you'll use. The HEAD and OPTIONS request method aren't used very often. The chance that you won't ever use this is quite large.