Preface
In our daily development process, we all involve more or less API interface testing. For example, some friends use Chrome's Postman plug-in, or use Firefox's restclient and other tools. In fact, these tools are one of the very effective ways to test API interfaces. The author has been using Postman to complete the testing of API interfaces. Today, the author recommends another very useful gadget that can help readers quickly test API interfaces. This tool is IDEA's Editor REST Client.
IDEA's Editor REST Client has been supported in IntelliJ IDEA 2017.3 version, and has added many features in 2018.1 version. In fact, it is an HTTP Client plugin for IntelliJ IDEA.
Get started
First, we can create an xxx.http file in any directory, as shown in the figure.
Here, we need to use ### to split HTTP requests and add comments later, as shown below.
### User login POST http://localhost:8088/oauth/token?grant_type=password&username=lgz&password=123456Accept: application/jsonContent-Type: application/json;charset=UTF-8Authorization: Basic client secretCache-Control: no-cache
Therefore, we get the response content.
Multi-environment configuration
During the development process, we usually have multiple sets of environments, such as development environment, test environment, pre-issue environment, production environment, etc. Therefore, it would be great if the Editor REST Client could do multi-environment configuration like Postman. In fact, Editor REST Client already supports this feature. We only need to create rest-client.env.json file and configure multiple environment information.
{ "development" : { "url" : "http://localhost:8088", "token" : "Bearer 4d74c7fb-0ef4-45ec-b3ff-902eaa3d116c" }, "test" : { "url" : "http://localhost:8089", "token" : "Bearer 4d74c7fb-0ef4-45ec-b3ff-902eaa3d116c" }, "preproduction" : { "url" : "http://activity.720ui.com", "token" : "Bearer 4d74c7fb-0ef4-45ec-b3ff-902eaa3d116c" }, "product" : { "url" : "http://activity.720ui.com", "token" : "Bearer 4d74c7fb-0ef4-45ec-b3ff-902eaa3d116c" }}At this time, transform the previous URL and transform http://localhost:8088 into url instead.
POST /oauth/token?grant_type=password&username=lgz&password=123456
Here, the overall effect we get.
Detailed explanation of the case
Now, let's write a complete case.
### Create user information POST /v1/m/usersAccept : application/jsonContent-Type : application/json;charset=UTF-8Authorization: { "username": "xiaoyue", "realname": "Xiaoyue", "password": "111111", "email": "[email protected]", "tel": "18305930000", "weixin": "LiangGzone", "sex": 1} ### Modify user information PUT /v1/m/users/723181Accept : application/jsonContent-Type : application/json;charset=UTF-8Authorization: CachePATCH-Control : no-cache{ "username": "xiaoyue"} ### Query user information GET /v1/c/users/lgz/usernameAccept : application/jsonContent-Type : application/json;charset=UTF-8Authorization: ### Query user information list GET /v1/c/users?keyword=Beam Accept : application/jsonContent-Type : application/json;charset=UTF-8Authorization:References
https://marketplace.visualstudio.com/items?itemName=humao.rest-clientt
Summarize
The above is the entire content of this article. I hope that the content of this article has certain reference value for everyone's study or work. If you have any questions, you can leave a message to communicate. Thank you for your support to Wulin.com.