import json
import requests #登录系统,并取到token值
url = 'http://test.xxxx.com:8060/api/gv-op/userAuth/login' header = { "Accept": "application/json, text/plain, */*", "Content-Type": "application/json", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36" } data = {"account": "guest_Pai_shz","password": "PW_Pai_shz"} res = requests.post(url=url, headers=header, data=json.dumps(data)) tt = json.loads(res.text) refreshToken = tt["data"]["refreshToken"] accessToken = tt["data"]["accessToken"] print(accessToken) print(refreshToken) #上传文件 header2={ 'accessToken':accessToken, 'refreshToken':refreshToken } up_url='http://test.lxxxxom:8060/api/gv-op/deviceVersion/info'
files={'file':open('D:\\210508_OTAfront.bin','rb'), 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'form-data' } data2_value={ "description":"aad","deviceModel":"407","firmwareVersion":"ccfd","hardwareVersion":"bb","updateDescription":"dddd", 'Content-Disposition': 'form-data','name':"file",'filename':'210508_OTAfront.bin' } data2={ 'deviceVersion':data2_value } res2=requests.post(url=up_url,headers=header2,data=data2,files=files) # print(json.loads(res2.text))
|