telegram-bot-api: Error getting file: [400] Bad Request: invalid file_id

2 days ago all works fine, but today when I try to use getFile() server returns error invalid file id in logs I have found that update that server receives contains to document object and second document has file_id that works with server, but I dont know how to get this second file_id My code:

@SneakyThrows
    public String getFileUrl(Message message) {
        String fileId = message.hasVideo() ? message.getVideo().getFileId() : message.getDocument().getFileId();

        GetFile getFile = new GetFile();
        getFile.setFileId(fileId);
        File file = telegramBot.execute(getFile);
        return file.getFilePath();
    }

Server logs:

2023-10-31 16:19:00 [ 3][t 1][1698758340.507417440][Td.cpp:4104][#6410708698][!Td][&td_requests]        Sending update: updateNewMessage {
2023-10-31 16:19:00   message = message {
2023-10-31 16:19:00     id = 428867584
2023-10-31 16:19:00     sender_id = messageSenderUser {
2023-10-31 16:19:00       user_id = 2027231413
2023-10-31 16:19:00     }
2023-10-31 16:19:00     chat_id = 2027231413
2023-10-31 16:19:00     sending_state = null
2023-10-31 16:19:00     scheduling_state = null
2023-10-31 16:19:00     is_outgoing = false
2023-10-31 16:19:00     is_pinned = false
2023-10-31 16:19:00     can_be_edited = false
2023-10-31 16:19:00     can_be_forwarded = true
2023-10-31 16:19:00     can_be_saved = true
2023-10-31 16:19:00     can_be_deleted_only_for_self = true
2023-10-31 16:19:00     can_be_deleted_for_all_users = true
2023-10-31 16:19:00     can_get_added_reactions = false
2023-10-31 16:19:00     can_get_statistics = false
2023-10-31 16:19:00     can_get_message_thread = false
2023-10-31 16:19:00     can_get_viewers = false
2023-10-31 16:19:00     can_get_media_timestamp_links = false
2023-10-31 16:19:00     can_report_reactions = false
2023-10-31 16:19:00     has_timestamped_media = true
2023-10-31 16:19:00     is_channel_post = false
2023-10-31 16:19:00     is_topic_message = false
2023-10-31 16:19:00     contains_unread_mention = false
2023-10-31 16:19:00     date = 1698758341
2023-10-31 16:19:00     edit_date = 0
2023-10-31 16:19:00     forward_info = null
2023-10-31 16:19:00     interaction_info = null
2023-10-31 16:19:00     unread_reactions = vector[0] {
2023-10-31 16:19:00     }
2023-10-31 16:19:00     reply_to = null
2023-10-31 16:19:00     message_thread_id = 0
2023-10-31 16:19:00     self_destruct_type = null
2023-10-31 16:19:00     self_destruct_in = 0.000000
2023-10-31 16:19:00     auto_delete_in = 0.000000
2023-10-31 16:19:00     via_bot_user_id = 0
2023-10-31 16:19:00     author_signature = ""
2023-10-31 16:19:00     media_album_id = 0
2023-10-31 16:19:00     restriction_reason = ""
2023-10-31 16:19:00     content = messageDocument {
2023-10-31 16:19:00       document = document {
2023-10-31 16:19:00         file_name = "2027231413.mp4"
2023-10-31 16:19:00         mime_type = "video/mp4"
2023-10-31 16:19:00         minithumbnail = null
2023-10-31 16:19:00         thumbnail = thumbnail {
2023-10-31 16:19:00           format = thumbnailFormatJpeg {
2023-10-31 16:19:00           }
2023-10-31 16:19:00           width = 320
2023-10-31 16:19:00           height = 180
2023-10-31 16:19:00           file = file {
2023-10-31 16:19:00             id = 1
2023-10-31 16:19:00             size = 13985
2023-10-31 16:19:00             expected_size = 13985
2023-10-31 16:19:00             local = localFile {
2023-10-31 16:19:00               path = ""
2023-10-31 16:19:00               can_be_downloaded = true
2023-10-31 16:19:00               can_be_deleted = false
2023-10-31 16:19:00               is_downloading_active = false
2023-10-31 16:19:00               is_downloading_completed = false
2023-10-31 16:19:00               download_offset = 0
2023-10-31 16:19:00               downloaded_prefix_size = 0
2023-10-31 16:19:00               downloaded_size = 0
2023-10-31 16:19:00             }
2023-10-31 16:19:00             remote = remoteFile {
2023-10-31 16:19:00               id = "AAMCAgADGQEAAgGZZUD-xREGMToalDt7vN6h1dAwtHUAAis0AAKm_QlKcH6aTWZbkE8BAAdtAAMwBA"
2023-10-31 16:19:00               unique_id = "AQADKzQAAqb9CUpy"
2023-10-31 16:19:00               is_uploading_active = false
2023-10-31 16:19:00               is_uploading_completed = true
2023-10-31 16:19:00               uploaded_size = 13985
2023-10-31 16:19:00             }
2023-10-31 16:19:00           }
2023-10-31 16:19:00         }
2023-10-31 16:19:00         document = file {
2023-10-31 16:19:00           id = 2
2023-10-31 16:19:00           size = 69718878
2023-10-31 16:19:00           expected_size = 69718878
2023-10-31 16:19:00           local = localFile {
2023-10-31 16:19:00             path = ""
2023-10-31 16:19:00             can_be_downloaded = true
2023-10-31 16:19:00             can_be_deleted = false
2023-10-31 16:19:00             is_downloading_active = false
2023-10-31 16:19:00             is_downloading_completed = false
2023-10-31 16:19:00             download_offset = 0
2023-10-31 16:19:00             downloaded_prefix_size = 0
2023-10-31 16:19:00             downloaded_size = 0
2023-10-31 16:19:00           }
2023-10-31 16:19:00           remote = remoteFile {
2023-10-31 16:19:00             id = "BQACAgIAAxkBAAIBmWVA_sURBjE6GpQ7e7zeodXQMLR1AAIrNAACpv0JSnB-mk1mW5BPMAQ"
2023-10-31 16:19:00             unique_id = "AgADKzQAAqb9CUo"
2023-10-31 16:19:00             is_uploading_active = false
2023-10-31 16:19:00             is_uploading_completed = true
2023-10-31 16:19:00             uploaded_size = 69718878
2023-10-31 16:19:00           }
2023-10-31 16:19:00         }
2023-10-31 16:19:00       }
2023-10-31 16:19:00       caption = formattedText {
2023-10-31 16:19:00         text = "/upload"
2023-10-31 16:19:00         entities = vector[1] {
2023-10-31 16:19:00           textEntity {
2023-10-31 16:19:00             offset = 0
2023-10-31 16:19:00             length = 7
2023-10-31 16:19:00             type = textEntityTypeBotCommand {
2023-10-31 16:19:00             }
2023-10-31 16:19:00           }
2023-10-31 16:19:00         }
2023-10-31 16:19:00       }
2023-10-31 16:19:00     }
2023-10-31 16:19:00     reply_markup = null
2023-10-31 16:19:00   }
2023-10-31 16:19:00 }
2023-10-31 16:19:00 [ 3][t 1][1698758340.507489442][UpdatesManager.cpp:632][#6410708698][!UpdatesManager]       Update PTS from 425 to 426 from process pending updates fast path

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

This file_id was received from api.telegram.org. You can’t use it with the local Bot API server.