idea中HTTP测试支持
主要提供了两种,一种是图形界面的,一种是curl式的
- 需求
请求https://httpbin.org/post 请求格式是application/json ,requestBody是{ "id": 999, "value": "content" }
图形界面
- 选择tools--->http client --> test restful web service,出现如下界面,填写示例请求参数
命令界面
- 通过菜单打开命令界面,进行文件命名,按示例代码进行测试
示例代码
POST https://httpbin.org/post
Content-Type: application/json
{
"id": 999,
"value": "content"
}
- 选择tools--->http client --> open http requests collection, 再依次可以查看历史记录。
### 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--
###