跳转到内容

REST Client

基本使用

新建.http后缀的文件

http
### GET 请求示例
GET https://api.example.com/users

添加请求头

直接写在 URL 下面,每一行就是一个 header

http
### POST JSON 示例
POST https://api.example.com/login
Content-Type: application/json

POST请求添加参数

http
### POST JSON 示例
POST https://api.example.com/login
Content-Type: application/json

{
  "username": "admin",
  "password": "123456"
}

POST表单提交

http
POST https://api.example.com/form
Content-Type: application/x-www-form-urlencoded

username=admin&password=123456

多环境

以此创建目录文件:src/__http__/http-client.env.jsonsrc/__http__/login.httpresponse.json。login.http选择dev环境

json
{
	"dev": {
		"baseUrl": "http://192.168.0.50:8888",
		"headers": {
			"CLIENT-TOC": "Y",
			"TENANT-ID": "1",
			"Authorization": "Basic xxxxx"
		}
	},
	"prod": {
		"baseUrl": "https://api.example.com",
		"headers": {
			"CLIENT-TOC": "Y",
			"TENANT-ID": "1"
		}
	}
}
http
### 登录
POST {{baseUrl}}/oauth2/token
Content-Type: application/x-www-form-urlencoded

grant_type = xxx &
mobile = APP-MINI@xxx
# 响应报文存储
> ./response.json

Will Try My Best.