Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
10 views1 page

All

The document explains the five main HTTP methods used in APIs: GET, POST, PUT, DELETE, and PATCH, detailing their functions in resource interaction. GET retrieves data, POST creates new resources, PUT updates entire resources, DELETE removes resources, and PATCH modifies specific parts of a resource. Additionally, it describes the use of annotations like @GetMapping, @PostMapping, @PutMapping, @DeleteMapping, and @PatchMapping for mapping these HTTP methods to specific handler methods in web service endpoints.

Uploaded by

3future1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

All

The document explains the five main HTTP methods used in APIs: GET, POST, PUT, DELETE, and PATCH, detailing their functions in resource interaction. GET retrieves data, POST creates new resources, PUT updates entire resources, DELETE removes resources, and PATCH modifies specific parts of a resource. Additionally, it describes the use of annotations like @GetMapping, @PostMapping, @PutMapping, @DeleteMapping, and @PatchMapping for mapping these HTTP methods to specific handler methods in web service endpoints.

Uploaded by

3future1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

In APIs, GET, PUT, POST, DELETE, and PATCH are HTTP methods used to interact with

resources. GET retrieves data, POST creates new resources, PUT updates entire
resources, DELETE removes resources, and PATCH updates specific parts of a
resource.
HTTP Methods Explained: Understanding GET, POST, PUT, and ...
Here's a breakdown:
GET:
Retrieves data from a specified resource. Think of it like asking a server for
information.
POST:
Sends data to the server to create a new resource. For example, submitting a form
to create a new user account.
PUT:
Replaces an existing resource with the data provided in the request. If the
resource doesn't exist, it may be created.
DELETE:
Removes a resource from the server.
PATCH:
Modifies only the specific fields of a resource, leaving other fields untouched.
Example:
Let's say we have a resource representing a user with fields like id, name, and
email.
GET /users/123 would retrieve the user with ID 123.
POST /users with a request body containing {"name": "John Doe", "email":
"[email protected]"} would create a new user.
PUT /users/123 with a request body containing {"name": "John Smith", "email":
"[email protected]"} would replace the entire user with ID 123 with the new
data.
DELETE /users/123 would remove the user with ID 123.
PATCH /users/123 with a request body containing {"email": "[email protected]"}
would only update the email of the user with ID 123.

@GetMapping: It maps the HTTP GET requests on the specific handler method. It is
used to create a web service endpoint that fetches It is used instead of using:
@RequestMapping(method = RequestMethod.GET)
@PostMapping: It maps the HTTP POST requests on the specific handler method. It is
used to create a web service endpoint that creates It is used instead of using:
@RequestMapping(method = RequestMethod.POST)
@PutMapping: It maps the HTTP PUT requests on the specific handler method. It is
used to create a web service endpoint that creates or updates It is used instead of
using: @RequestMapping(method = RequestMethod.PUT)
@DeleteMapping: It maps the HTTP DELETE requests on the specific handler method. It
is used to create a web service endpoint that deletes a resource. It is used
instead of using: @RequestMapping(method = RequestMethod.DELETE)
@PatchMapping: It maps the HTTP PATCH requests on the specific handler method. It
is used instead of using: @RequestMapping(method = RequestMethod.PATCH)

You might also like