RESTful Web Services Basics
Mohamad's interest is in Programming (Mobile, Web, Database and Machine Learning). He is studying at the Center For Artificial Intelligence Technology (CAIT), Universiti Kebangsaan Malaysia (UKM).
HTTP Methods and Status Codes:
GET: Retrieve information from the server (e.g., read a resource).
POST: Send data to the server to create a new resource.
PUT: Update an existing resource on the server.
DELETE: Remove a resource from the server.
Status Codes:
200 OK: Successful GET, PUT, DELETE, or POST.
201 Created: Successful POST that results in a new resource.
204 No Content: Successful request that doesn’t return a body.
400 Bad Request: Client-side error.
404 Not Found: Resource not found.
500 Internal Server Error: Server-side error.
Designing Resource URIs:
Use nouns to represent resources (e.g.,
/users,/orders).Use sub-resources for relations (e.g.,
/users/{id}/orders).Be consistent in URI design (e.g., use hyphens or underscores).