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()
2
Answers
try this one:
sendDocument
method needs 2 required parameters:chat_id
anddocument
,you already provided the
chat_id
, to add thedocument
field you should do :