vscode http request plugin: rest client a year ago
除了postman、myapi, vscode 也有一款好用的http测试工具 - REST Client
安装好插件后我们就可以测试了
首先我们得创建一个文件tests.http
,然后把http请求写在里面, 如下所示:
如果想测试接口,直接点击上面的send request即可
下面是一些示例:
GET
GET https://example.com/comments/1
# 指定http版本号
GET https://example.com/topics/1 HTTP/1.1
GET https://example.com/comments?page=2&pageSize=10
GET https://example.com/comments
?page=2
&pageSize=10
POST
# 指定body,注意header和body之间需要一个空行
POST https://example.com/comments HTTP/1.1
content-type: application/json
{
"name": "sample",
"time": "Wed, 21 Oct 2015 18:27:50 GMT"
}
# 指定body
POST https://example.com/comments HTTP/1.1
Content-Type: application/xml
Authorization: token xxx
<request>
<name>sample</name>
<time>Wed, 21 Oct 2015 18:27:50 GMT</time>
</request>
# 指定body为本地文件
POST https://example.com/comments HTTP/1.1
Content-Type: application/xml
Authorization: token xxx
< C:\Users\Default\Desktop\demo.xml
# 指定body为本地文件
POST https://example.com/comments HTTP/1.1
Content-Type: application/xml
Authorization: token xxx
< ./demo.xml
文档详情见:https://marketplace.visualstudio.com/items?itemName=humao.rest-client