用python来测试接口POST的方式提交json以及传字符串(格式application/x-www-form-urlencoded)写的一个小的demo类。
开发工具: Visual Studio Code
python版本: Python 3.8.5 32-bit
一、调用接口使用字符串(格式application/x-www-form-urlencoded)来传参。
如图:
代码如下:
import requests
def sendFBox(username,password,scope,client_id,client_secret,grant_type):
values = {
"username":user_username,
"password":password,
"scope":scope,
"client_id":client_id,
"client_secret":client_secret,
"grant_type":grant_type
}
post_url='https://account/core/connect/token' # 接口地址
try:
req=requests.po