我正在尝试以zip格式下载响应,而使用Java for Rest API会包含多个文件。在邮递员中,我已经给出了请求,并能够通过单击“发送并下载”将响应保存为一个zip。 尝试使用以下代码将响应下载为zip格式,但是如果响应中包含多个文件,则不适用于该响应。仅在响应中包含单个文件时有效。
代码:
import pypyodbc
conn_str = ('Driver={SQL Server};Server=*****************;Trusted_Connection=yes;')
con = pypyodbc.connect(conn_str)
cur = con.cursor()
cur.execute("SELECT DISTINCT TDate, Report, Records, Status from Elig_Own.DST_Report_Status_Test")
rows = cur.fetchall()
for row in rows:
TDate = row[0] # first item in the tuple iterable
Report = row[1] # Second
Records = row[2] # third
Status = row[3] # fourth
cur.execute("truncate table Elig_own.DST_Report_Status_Test")
cur.execute('''INSERT into Elig_Own.DST_Report_Status_Test (TDate, Report, Records, Status)
VALUES (?, ?, ?, ?)''',(TDate, Report, Records, Status))
con.commit()
con.close()