我想在请求正文中传递一些数据,但我使用的是 GET 请求,因为我只想修改此数据并将其发回。
我知道在 GET 请求中使用 body 是一种不好的做法。
但是如果我想构建正确的 RESTful 服务,我该怎么办?
附注我不会更改服务器上的任何对象。 我不会在服务器上放置任何新对象。
最佳答案
您需要一个POST
。类似的东西
POST /hashes
{
"myInput": ...
}
响应将是散列值。没有规定创建的资源必须由服务器保留。
来自RFC :
The action performed by the POST method might not result in a
resource that can be identified by a URI. In this case, either 200
(OK) or 204 (No Content) is the appropriate response status,
depending on whether or not the response includes an entity that
describes the result.
关于rest - 通过 GET 请求在 BODY 中传递参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23200554/