What Are REST API Methods?
What Are Rest API Methods?
We use certain HTTP methods to develop an application with Rest API. In this article, I will discuss these methods and the purposes for which they are used.
GET
This is the method the client should send to the server in order to retrieve data from the server.
GET /users
To fetch all users
GET /users/{id}
To fetch only the user with the specified id value
POST
This is the method the client should send to the server in order to add new data to the server.
POST /users/
To add a new user
PUT
This is the method the client should send to the server in order to change all data of a resource on the server.
PUT /users/
To edit user information
PATCH
This is the method the client should send to the server in order to change just a specific part of a resource on the server.
PATCH /users/
To edit user information
DELETE
This is the method the client should send to the server in order to delete data from the server.
DELETE /users/{id}
To delete a user
Besides the methods above, there are also a few others such as "COPY", "PURGE", "LINK", and "UNLINK", but they are not used very often.
Difference Between PUT and PATCH
PUT /users/1{"username": "urhoba","email": "urhoba@urhoba.net" // New email address}
PATCH /users/1{"email": "urhoba@urhoba.net" // New email address}


Yorum Gönder