Postman interface test - use postman to run the interface

Postman is a software that simulates sending interface requests, and is generally used for interface debugging and testing. Recently, the postman tool has been used a lot, so I specially organize and summarize the experience of using postman.

1. Postman download and usage instructions

Postman official download address:

https://www.getpostman.com/downloads/

Postman official documentation: https://learning.getpostman.com/docs/postman/sending_api_requests/requests/

Enter the postman download page through the official address. On this page, you can get the installation packages of the three systems of windows, mac and linux.

2. Description of filling information for sending request

After downloading and installing postman, create a Collection to store the request, and create a request in the Collection, where we fill in and send the request.

2.1 Send the parameters filled in the request

If you want to send a request, then in the postman interface, you need to determine the following information:

  • Request type: Select the interface type we need to send in the request type drop-down column, such as post, get.

  • Request address: In the request address bar, enter the url of our request address.

  • Request header: The header information requested by the request is filled in Headers.

  • Request parameters: The parameters sent by the request, filled in Params or Body.

  • Request authentication: request to send the required authentication information, fill in Authorization.

2.2 About the type of request parameters:

In postman, request parameters are divided into two parts, params and body. Generally, when using a get request, fill in the parameters in Params, and then the program will automatically splicing them to the request address. For other requests such as post, the parameters are placed in the body separately. . Here is an overview of how to fill in different request parameter types:

  • params : Fill in the data using key-value.

  • none : The request has no parameters and no body.

  • form-data : Fill in the data in the key-value way, and you can upload the file type.

  • x-www-from-urlencoded : use key-value to fill in the data, and the file type cannot be uploaded

  • raw : text, json, xml, html, and Javascript formats can be used.

  • binary : Upload binary data, generally used to upload files, and only one can be uploaded at a time.

  • GraphQL : Currently in the beta version of postman, it is said to be an API query language.

3. Example of sending request

3.1 Send a post request

1 Get interface information

If it is an online web project, you can open the console through F12, find the interface after refreshing the page, and click to view the request address, request type, request header, request parameter type and content we need on the right.

2 copy request parameters

When the interface information is obtained and filled in postman, the request parameters are generally the most content. When I first contacted postman, I copied the parameters one by one. Later, I found out that there is a one-click copy and paste method.

Step 1: On the console page of F12, click view source in the request parameter (Request Payload), and then copy the content (the format of key-value can directly copy the format of key:value, because the source is separated by = , what postman recognizes is: symbol).

Step 2: On the postman parameter filling page, click Bulk Edit to enter the full editing mode, then paste it here, and click Key-value Edit again to return to the key-value mode, and the one-to-one corresponding parameter format will be displayed.

3 Fill in the information to postman run

As shown in the figure, in this interface, neither authentication nor headers are filled in information, because this interface does not require authentication, so Authorization is not filled in; and in the header, postman will automatically generate a header according to the format of your body internal parameters Content-Type information in.

After completing the filling, click send to send the request, and the response information will be displayed below.

3.2 Send a get request

Same as the above steps, we get the interface information and fill it in postman. It should be noted here that the parameters of the get request are also displayed in params, because when sending the get request, the parameters will be spliced ​​after the Url.

Therefore, when copying the url, the input parameters will be copied together, and then displayed in the params in postman for easy display and modification.

If my blog is helpful to you, if you like my blog content, please "Like", "Comment", "Favorite" with one click!


Finally: In order to give back to the die-hard fans, I have compiled a complete software testing video learning tutorial for you. If you need it, you can get it for free【保证100%免费】

Software Testing Interview Documentation

We must study to find a high-paying job. The following interview questions are the latest interview materials from first-tier Internet companies such as Ali, Tencent, and Byte, and some Byte bosses have given authoritative answers. Finish this set The interview materials believe that everyone can find a satisfactory job.

Guess you like

Origin blog.csdn.net/myh919/article/details/131563709