I´m trying to send a file using the code below which results in the following error:
ValueError: too many values to unpack (expected 2)
How can I fix this?
bot_token = "" bot_chatId = "" a = open('/home/scrapy/diff.csv', 'rb') send_document = 'https://api.telegram.org/bot' + bot_token +'/sendDocument?' data = { 'chat_id': bot_chatId, 'parse_mode':'HTML', 'caption':'This is my file' } r = requests.post(send_document, data=data, files=open('/home/scrapy/diff.csv','rb'),stream=True) print(r.url) return r.json()
Advertisement
Answer
try this one:
r = requests.post(send_document, data=data, files={'document': a},stream=True)