How to use the request body and request parameters of the GET and DELETE methods

How to use the request body and request parameters of the GET and DELETE methods

REST APIは、URIとHTTPメソッドの組み合わせで成り立っています。

| HTTP Method | Meaning |
| :– | :– | Get | Get
| GET | Get |
| POST | Register,etc. |
| PUT | Update |
DELETE | DELETE |

Request parameters for GET and DELETE methods

Request parameters (also called query parameters or GET parameters) are used in the GET method, but can also be used in DELETE.

However, given that query = query and the term GET parameter, it is not desirable to use request parameters (?name=takahashi&age=20) in the GET method.

If a request parameter is needed for deletion, I think it is better to regard it as a complex deletion process and change it to POST.

Request body for GET and DELETE methods

The GET and DELETE methods can actually set data in the request body.

In that case, setting content-length is required. (Originally, setting content-length is optional for GET,DELETE.)

However, many web servers do not support this request body in the GET,DELETE method either, so I think the conclusion would be to change from the GET,DELETE method to the POST method for complex processing.

コメント

タイトルとURLをコピーしました