# debugtalk.py
import json
import os
from datetime import time, datetime
import requests
from urllib3 import encode_multipart_formdata
from LeonDjango.settings import BASE_DIR
file_path = os.path.join(BASE_DIR, '1.txt')
filename = '1.txt'
import datetime
import time
def sendFile_testEnv(policyId, docType):
with open(file_path, mode="r", encoding="utf8")as f: # 打开文件
file = {
"fileData": (filename, f.read()), # 引号的file是接口的字段,后面的是文件的名称、文件的内容
'uploadExtraData': json.dumps({"docType": docType, "policyId": policyId, "docName": "1", "remark": ""})
}
encode_data = encode_multipart_formdata(file)
file_data = encode_data[0]
headers_from_data = {
"Content-Type": encode_data[1],
"Authorization": "ZjOTZhZmVjMzEwMzM3MDgzZmU5NGI="
}
url = "https://api/pa-service/api/std/b2b/policies/docs"
response = requests.post(url=url, headers=headers_from_data, data=file_data)
print(response.text)
def effectDate():
return (datetime.date.today() + datetime.timedelta(days=1)).strftime('%d/%m/%Y') + "T00:00:00.000"
def experiyDate():
return (datetime.date.today() + datetime.timedelta(days=366)).strftime('%d/%m/%Y') + "T00:00:00.000"
def random():
return time.strftime("%Y%m%d%H%M%S", time.localtime())
接口测试文档上传 ---在网上找不到请看这篇
最新推荐文章于 2021-02-10 13:31:55 发布