Error with WrongFileIdentifier in aiogram bot

Problem Overview

I’m encountering a WrongFileIdentifier error while attempting to send media files with my Telegram bot developed using the aiogram framework. Although the bot initializes correctly and displays the proper name, it crashes when sending either photos or video notes.

Error Information

The key error message is:

aiogram.utils.exceptions.WrongFileIdentifier: Wrong file identifier/http url specified

This issue arises with both send_photo() and send_video_note() functions. I have followed a tutorial but only changed the configuration file to include my bot token and user ID, yet the media sending operations are failing.

Code Example

# This is a structure similar to what I'm working on
@dp.message_handler(commands=['photo'])
async def process_photo_request(msg: types.Message):
    await bot.send_photo(msg.from_user.id, CAT_IMAGE_ID)

@dp.message_handler(commands=['video_note'])
async def process_video_note_request(msg: types.Message):
    await bot.send_video_note(msg.from_user.id, SPHERE_VIDEO_ID)

Steps Taken

I precisely copied the code from the tutorial source and modified only the configuration parameters. The bot connects without issues but fails during media command handling. Has anyone experienced this file identifier issue? What might cause the wrong file identifier error?

Had the same issue when I started with aiogram. Those file IDs from tutorials only work for that specific bot - they won’t work with yours. I switched to HTTP URLs for public images first: await bot.send_photo(msg.from_user.id, 'https://example.com/image.jpg'). After you send a file successfully, Telegram gives you back the new file ID in the response. Save that and reuse it. You can tell if your file IDs are valid by checking the format - they’re long strings with specific patterns that match your bot.

yeah, same thing happened to me. you’re probably using file ids from the tutorial that don’t work with your bot. upload files directly with file paths instead of those cat_image_id variables. try await bot.send_photo(msg.from_user.id, open('cat.jpg', 'rb')) or just use urls from the internet.

The issue you’re facing likely stems from using file identifiers that belong to another bot. Each Telegram bot generates its own unique file IDs, and any attempt to use IDs from a different bot will inevitably lead to the WrongFileIdentifier error. To rectify this, you should upload the media files directly to your current bot for it to generate the correct file IDs. Alternatively, consider using aiogram’s InputFile feature, which allows you to send local files without having to manage file IDs.