Junior
What standard methods does EndPoint use?
sobes.tech AI
Answer from AI
Standard HTTP methods commonly used for interacting with an EndPoint:
- GET: Retrieve data from the server. Does not change the resource's state.
- POST: Send data to the server to create a new resource or perform an action.
- PUT: Update or create a resource on the server. If the resource exists, it is updated; if not, it is created.
- PATCH: Partially update a resource on the server. Only the changed fields are sent.
- DELETE: Remove a resource from the server.
- HEAD: Retrieve response headers without the message body. Used to check resource existence or metadata.
- OPTIONS: Get information about available methods and other interaction options with the resource.
Example of using GET in curl:
# Get information about user with ID 123
curl http://api.example.com/users/123
Example of using POST with a JSON body:
# Create a new user
curl -X POST -H "Content-Type: application/json" -d '{"name": "John Doe", "email": "john.doe@example.com"}' http://api.example.com/users
Example of using PUT for updating:
# Update user data with ID 123
curl -X PUT -H "Content-Type: application/json" -d '{"name": "Jane Doe"}' http://api.example.com/users/123
Example of using DELETE:
# Delete user with ID 123
curl -X DELETE http://api.example.com/users/123
These methods define the type of operation the client wants to perform on the resource identified by the URL EndPoint.