The strongest and most detailed postman interface test tutorial in the whole network

Contents: Guide

1. Introduction and installation

Introduction to Postman:
Postman is a powerful Chrome plugin for debugging web pages and sending HTTP requests for web pages

It provides powerful Web API & HTTP request debugging. It is able to send any type of HTTP request (GET, HEAD, POST, PUT…) with any number of parameters + headers

Postman function:
mainly used to simulate network request packets to quickly create request playback, manage requests to quickly set network proxy

Postman installation:
1. Download:
Official website download: https://www.getpostman.com/downloads/, select "Download" on the page, and choose 32-bit download or 64-bit download according to your computer configuration

 2. Double-click the downloaded installation package

 3. Postman is free of installation, double-click the installation package, and it will be automatically installed on the local computer

 4. View the Postman interface, as shown in the figure below, indicating that the installation is successful

2. Interface introduction

Postman interface menu function introduction:

 

 

3. Send a GET request

Send get request 1:
page access request (get method): https://www.baidu.com/s?wd=LeBron James
This get request is a Baidu search request, and different query results are returned by entering different keywords
in Enter the above link in the input box behind Get, and click the send button to get the corresponding return information

 Send get request 2:
WeChat public platform developer documentation is a platform for operators to provide information and services to WeChat users through public accounts, and the public platform development interface is the basis for providing services. Developers create public accounts on the public platform website, After obtaining the interface permission, you can help the development by reading this interface document

The address is: https://mp.weixin.qq.com/wiki/home/

The following uses the interface of the WeChat public platform as an example to explain the use of the postman tool

1. First enter the Start Development – ​​interface test number application menu, scan the WeChat to generate a test number
2. After scanning the code, generate appID and appsecret
3. Then enter Start Development – ​​get the interface call credentials, there is a get to get the access token Request interface
4. Same as the previous Baidu search request, enter postman, and then check the returned results.
5. The returned result is: {"access_token":"ACCESS_TOKEN", "expires_in":7200}, the data is in json format, as
shown in the figure below:
 

4. Send a POST request

There is an interface for creating user groups in the developer documentation of the WeChat public platform, and the request type of this interface is post

Use postman to operate the interface request as follows:
1. Enter user management - user group management - create a group, view interface information
2. Enter into postman
as shown in the following figure:

 

Description:
1. The interface needs to submit data to the server in json format. So after selecting post, then click on body - raw - drop down the data format and select JSON - fill in the required json data

2. This interface requires the access_token parameter, which is returned by the previous interface that obtained the interface call credentials, and the validity period can be used for 7200 seconds

Instructions for request parameter passing
Page access request (Post method):
the difference between form-data, x-www-form-urlencoded, raw, and binary

form-data
is the multipart/form-data in the http request, which will process the data of the form into a message, with labels as units and separated by separators. Both key-value pairs and files can be uploaded. When the uploaded field is a file, there will be Content-Type to describe the file type; content-disposition, used to describe some information of the field; due to boundary isolation, multipart/form-data can upload both files and keys value pair, which uses key-value pairs, so multiple files can be uploaded

x-www-form-urlencoded
is application/x-www-from-urlencoded, which converts the data in the form into key-value pairs

raw
can upload text in any format, such as text, json, xml, html, etc.

Binary
is equivalent to Content-Type: application/octet-stream. From the literal meaning, only binary data can be uploaded. It is usually used to upload files. Since there is no key value, only one file can be uploaded at a time.

The difference between multipart/form-data and x-www-form-urlencoded
multipart/form-data : You can upload binary data such as files, or upload form key-value pairs, but it will be converted into a piece of information
x-www-form-urlencoded in the end : Only key-value pairs can be uploaded, and the key-value pairs are separated by intervals

The difference between the Get method and the Post method
1. Get is to obtain data from the server, and post is to transmit data to the server

2. The security of get is very low, and the security of post is relatively high. But the execution efficiency is better than the Post method

3. The security of POST is higher than that of GET. Note: The security mentioned here is not the same concept as the "security" mentioned above in GET. The above "safety" means no data modification, but the meaning of security here is the real meaning of security, for example: submitting data through GET, the user name and password will appear on the URL in plain text, because (1) the login page may be blocked Browser cache, (2) Others can view the history of the browser, so others can get your account and password. In addition, using GET to submit data may also cause Cross-site request forgery attacks

To sum up, Get is a request to send data to the server, and Post is a request to submit data to the server. In FORM (form), Method defaults to "GET". In essence, GET and POST are just sending mechanisms. different, not one takes one
 

5. Detailed explanation of JSON data

JSON (JavaScript Object Notation), similar to XML, is a data exchange format. For example, if Java generates a data and wants to send it to JavaScript, in addition to using XML, you can also use JSON

The advantage of JSON over XML is that it is easy to express

Official website: http://www.json.org/

Website for online verification of JSON structure: http://www.bejson.com/jsonviewernew/

Note: JSON is not a document format, there is no *.json document, generally JSON format documents are stored in txt, and XML can be a standard

JSON data structure
JSON has two data structures:
1.Map, also known as object; {...}
is simply a Map in Java, given in the form of name-value pairs, and the name and value are separated by ":" Open, use "," to separate the two Maps, the general expression is as follows:
{'key1':'value1', 'key2':'value2'}

2.Array; […]
is an array in the ordinary sense.
The general form is as follows:
['arr1', 'arr2', 'arr3'];

 

The value in the figure can be the following values:
string, number, object, array, true, false, null
Summary:
1. There are only two data structures in JSON
2. It can be nested, for example, Object can be nested in Array
3 .Remember: Object is represented by {}, and Array is represented by []

Formatting and view of json data:
1. Enter the website: http://www.bejson.com/
2. Enter json-related – json view, and then paste the json data

Guess you like

Origin blog.csdn.net/lzz718719/article/details/131579642