rest - 通过 GET 请求在 BODY 中传递参数

标签 rest get restify

我想在请求正文中传递一些数据,但我使用的是 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/

相关文章:

node.js - Cloudfoundry 上的 Restify 'invalid ELF header'

Azure Graph API - 批准 PIM 请求

java - 如何在@GET中添加到Web服务迭代元素?

c# - 尝试调用 rest apis,但出现 http 请求异常

javascript - 如何在对话框按钮函数中获取 JS 变量

java - 如何在改造中获取访问 token

node.js - 类型 'locals' 上不存在属性 'Response'

javascript - 错误: invalid_request Missing required parameter: scope (Restify & Passportjs w/Google OAuth2)

rest - Grails错误Null指针异常访问GSP

android - 不涉及第 3 方应用程序时需要 OAUTH2 吗?