An HTTP method, also called an HTTP verb, specifies the type of operation a request asks a server to perform. In a RESTful web service, the method works with the URL: `/api/products/1` identifies a product, while the method says what to do with it. section 19.2.1
Table 19.3 HTTP methods and operations (view table figure)
| HTTP Method |
Description |
|---|---|
| GET |
This method is used to retrieve one or more data objects. |
| POST |
This method is used to create a new object. |
| PUT |
This method is used to update an existing object. |
| PATCH |
This method is used to update part of an existing object. |
| DELETE |
This method is used to delete an object. |
Use the method table when choosing a conventional operation: GET retrieves objects, POST creates one, PUT updates one, PATCH updates part of one, and DELETE removes one. section 19.2.1
In an ASP.NET Core minimal API, `MapGet` and `MapPost` can assign different handlers to routes under `/api/products`. GET `/api/products/1` retrieves one product; GET `/api/products` retrieves all products; POST `/api/products` reads a JSON request body and adds a product. Controllers can instead use attributes on action methods to declare which HTTP methods they accept. section 19.3 section 19.6
Send a POST request
Request the GET routes in a browser, then test creation with PowerShell: `Invoke-RestMethod http://localhost:5000/api/products -Method POST -Body (@{ Name="Swimming Goggles"; Price=12.75; CategoryId=1; SupplierId=1} | ConvertTo-Json) -ContentType "application/json"`. Entering the API URL in a browser does not send this POST request. section 19.3
Razor Pages also dispatch by method. An `OnGetAsync` handler can load a product for display; an `OnPostAsync` handler can accept a submitted price, update the product, and redirect. A form with `method="post"` and no action submits to its page URL. The example includes an anti-forgery field because POST requests without it are rejected. section 23.4.3









