Request library seven request methods

Each of the seven methods takes three basic parameters (method, URL, **kwargs)

Method: request mode, such as GET, PUT, and POST

Url: indicates the URL of the interface test

**kwargs: 13 parameters to control access

1. Request method

There are seven ways to select requests. Request (‘ get ‘, URL,**kwargs) using the request method.

Requests. The request (” head “, url, * * kwargs)

Requests. The request (” post “, url, * * kwargs)

Requests. The request (‘ put ‘, url, * * kwargs)

Requests. The request (” patch “, url, * * kwargs)

Requests. The request (” delete “, url, * * kwargs)

Requests. The request (‘ options’, url, * * kwargs)

Or, instead of using the Request method, use the seven encapsulated methods

Request. The get () method

Request. The head () method

Request. The post () method

Request. The put () method

Request. The patch () method

Request. The delete () method

2. **kwargs access control parameters

Params: dictionaries or sequences of bytes added as arguments to urls. Not only do you access urls, you can also carry parameters to the server.

Data: dictionary, byte sequence, or file object, used when submitting data to the server. The contents of data are not placed in the URL link, but in the corresponding location of the URL

Json: Data in JSON format, similar to data, is submitted to the server as part of the content.

Headers: dictionary, HTTP custom headers. Use this field to customize the HTTP protocol headers for accessing the URL.

Cookies: Dictionary or CookieJar that parses cookies from the HTTP protocol.

Auth: tuple, HTTP authentication.

Files: dictionary, used to transfer files to corresponding urls.

Timeout: Indicates the timeout period. The unit is second.

Proxies: Dictionary type, proxies, proxies, proxies

Allow — redirects: Boolean. The default value is 1, indicating whether redirects are allowed.

Stream: Boolean, 1 by default, indicating whether the obtained content is allowed to be downloaded immediately.

Verify: Indicates whether to authenticate SSL certificates. The default value is 1.

Cert: indicates the path of the local SSL certificate.

Interface test tool ApiPost, a domestic interface test and interface document generation tool, is recommended

The screenshot of correct operation is as follows: