Skip to content Skip to sidebar Skip to footer

Telegram Bot - Bad Request: Wrong File Identifier/http Url Specified

I have a weird problem with uploading a file to telegram via the sendDocument method. I am writing a bot in python with python-telegram-bot. I try to send a ZIP file to a user, giv

Solution 1:

A friend of mine helped me and we could fix the problem. Everything I did was correct according to the Telegram Bot API documentation, but as it looks the documentation is not complete.

The problem was the name of my file. The file must start with a letter. It cannot start with a number. So eg. test123.zip and t123.zip work but 123.zip or 1test.zip do not.

Update July 2020:

It seems that Telegram has changed it's filename policy. I just tried with the following names and every single one worked. My guess is they accept any filename now though not every client saves the file the same way:

\-\-\-\-.zip# in Telegram Desktop on Windows shown as "\-\-\-\-.zip" but saved as "_-_-_-_-.zip"# in Telegram on Android shown and saved as "----.zip"
hällo.zip1.zip
test\nme.zip# even with a filename with a literal new line character# in Telegram Desktop on Windows shown as "testme.zip" but saved as "test_me.zip"# in Telegram on Android shown and saved as "testme.zip"
tttt.zip
!test.zip
test!.zip
ttt.zip
t.zip
t1.zip
1t.zip000.zip
äääää.zip

tested as follows:

forpathin paths:
    print(path)
    chat.send_document('http://test.someurl.tdl/%s' % path, path)

Solution 2:

The filename must be at least 4 letters/digits long! (t12.zip wouldn't work)

Post a Comment for "Telegram Bot - Bad Request: Wrong File Identifier/http Url Specified"