I wanted to send a Document via Telegram bot API and my document is stored locally. I tried:
https://api.telegram.org/botToken/sendDocument?chat_id=-5278798&document=C:UsersAdministratorDesktopfile.txt
But I got Error…
Bad Request: failed to get HTTP URL content
This method only works in remote URLs, how to send documents via bot API?
2
Answers
You can’t use files local from your pc as I assume you have done via the
document=C:UsersAdministratorDesktopfile.txt
in your URLOn the docs it states "Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet." Telegram media Documents
Meaning you either have to use a file on the telegram servers or upload it to a website and send it via the URL you have uploaded it too.
Using python-telegram-bot you can send a local file using
send_document
method