比如我们要测试接口:identity/chatRecords/pages
已在Postman中有,那我们就可以直接从里面复制出Python脚本
新建: pagerequest.py
python
import requests
import json
url = "http://192.168.31.132:70/identity/chatRecords/pages"
payload = json.dumps({
"pageNumber": 1,
"pageSize": 50,
"field": "",
"isAscending": False,
"message": ""
})
headers = {
'accept': 'text/plain',
'Authorization': 'Bearer eyJhbGciOiJSUzIRJk-A',
'Content-Type': 'application/json-patch+json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
运行效果: