HTTP 请求存储在以
.http
或
.rest
为后缀的文件中,并且带有
API
小图标。
请求文件可以包含多个请求,多个请求中间用3个井号
###
隔开;如果是临时文件,每次执行请求后,会在请求下方生成对应请求结果的文件链接,按住
Ctrl + 鼠标左键
可以打开。
所有的请求结果,请求历史记录,cookies等信息会存放在
.idea
文件夹下,如下:
2.3 如何创建请求
使用右上角的快捷按钮创建请求,可以选择不同方式的请求,如下:
使用快捷键进行创建请求,例如输入
gtr
可以快速创建一个简单的 GET 请求,如下:
使用
Ctrl + J
快捷键可以查看创建 HTTP 请求的所有快捷键,如下:
通过
cURL
创建请求,点击右上角的
Convert form cURL
按钮,然后输入 cURL 地址即可自动转换,如下:
2.4 请求方式
GET
GET request with a header
Accept: application/json
GET request with parameter
GET https://httpbin.org/get?show_env=1
Accept: application/json
GET request with environment variables
GET {{host}}/get?show_env={{show_env}}
Accept: application/json
GET request with disabled redirects
@no-redirect
GET http://httpbin.org/status/301
GET request with dynamic variables
GET http://httpbin.org/anything?id={{KaTeX parse error: Expected 'EOF', got '}' at position 5: uuid}̲}&ts={{timestamp}}
POST
Send POST request with json body
Content-Type: application/json
{
“id”: 999,
“value”: “content”
}
Send POST request with body as parameters
Content-Type: application/x-www-form-urlencoded
id=999&value=content
Send a form with the text and file fields
Content-Type: multipart/form-data; boundary=WebAppBoundary
–WebAppBoundary
Content-Disposition: form-data; name=“element-name”
Content-Type: text/plain
Name
–WebAppBoundary
Content-Disposition: form-data; name=“data”; filename=“data.json”
Content-Type: application/json
< ./request-form-data.json
–WebAppBoundary–
Send request with dynamic variables in request’s body
Content-Type: application/json
{
“id”: {{$uuid}},
“price”: {{$randomInt}},
“ts”: {{$timestamp}},
“value”: “content”
}
PUT
PUT http://localhost:8080/person/put
Content-Type: application/json
{“name”: “陈皮”,“age”: 17}
PATCH
PATCH http://localhost:8080/person/put
Content-Type: application/json
{“name”: “陈皮”,“age”: 17}
鉴权方式
Basic authorization.
GET https://httpbin.org/basic-auth/user/passwd
Authorization: Basic user passwd
版权归原作者 2401_85155125 所有, 如有侵权,请联系我们删除。