将邮递员的POST请求导出到Python

时间:2020-10-08 12:27:12

标签: python postman quip

我正在尝试在python中运行POST请求。当我在Postman中测试时,它可以正常运行并导入文件。当我在Python中运行它时,我会出错。这会将存储在我的计算机中的电子表格发布到Quip中。我收到错误缺少参数'file'的错误。我已经尝试过移动几件事,但不确定自己缺少什么。这是我正在使用的东西:

import requests

url = "https://platform.quip.com/1/threads/import-file"

payload = {'type': 'spreadsheet'}
files = [
('file', open('/Users/admin/Documents/excel/logs/Output/test.xlsx','rb'))
]
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Bearer **************************='
}

response = requests.request("POST", url, headers=headers, data = payload, files = files)

print(response.text.encode('utf8'))

0 个答案:

没有答案