IntelliJ IDEA 自带的 HTTP Client 接口调用插件,吊打 Postman


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

GET https://httpbin.org/ip

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

POST https://httpbin.org/post

Content-Type: application/json

{

“id”: 999,

“value”: “content”

}

Send POST request with body as parameters

POST https://httpbin.org/post

Content-Type: application/x-www-form-urlencoded

id=999&value=content

Send a form with the text and file fields

POST https://httpbin.org/post

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

POST https://httpbin.org/post

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值