visual-studio-code - 使用 Visual Studio Code 的 REST 客户端扩展发出 POST 请求

标签 visual-studio-code

我正在使用 Visual Studio Code 的“REST 客户端”扩展 https://marketplace.visualstudio.com/items?itemName=humao.rest-client .

我可以使用以下代码发出 GET 请求:

GET https://some.domain.com/search/someuser/somekey?foo=5&bar=1

并且它有效。

现在,我需要发出 POST 请求并将 foobar 值作为表单字段传递。

我尝试过:

POST https://some.domain.com/search/
Authorization: Basic someuser somekey
Content-Type: application/x-www-form-urlencoded

'foo'='5'
'bar'='1'

但我收到错误“帖子正文中缺少必需的参数 foo”

使用 REST 客户端进行 POST 请求的正确语法是什么?

谢谢。

最佳答案

它的工作原理如下:

POST https://some.domain.com/search/
Authorization: Basic someuser somekey
Content-Type: application/x-www-form-urlencoded

foo='5'&bar='1'

  • 参数需要用&连接
  • 参数名称应该 不能放在引号之间

关于visual-studio-code - 使用 Visual Studio Code 的 REST 客户端扩展发出 POST 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56320708/

相关文章:

visual-studio-code - VSCode : Is it possible to suppress experimental decorator warnings

node.js - 在 AZURE 上上传 PERN 堆栈

keyboard - 如何在 Visual Studio Code 中的德语键盘上获得独立的反引号

c++ - 无法在 VS Code 上使用代码运行器运行 C++ 文件

visual-studio-code - 用于隐藏 console.log 命令的 VS Code 扩展?

visual-studio-code - 不需要的自动完成建议

python - vscode anacondapython 中 undefined variable url

azure - 将 azure 函数拉取到本地并安装 npm

visual-studio-code - VSCode for MacOS 中的 Typescript 导入不正确

git - vscode - 将一个分支 merge 到另一个分支