1

I'm new in telegram bot and try to send photo to user with this code:

await Bot.SendPhotoAsync(update.Message.Chat.Id, "http://182.126.201.42/" + "iisstart" + ".png");


but when i try run that code,get this error:

Bad Request: Wrong file identifier/HTTP URL specified


How can i solve that problem?thanks.

6
  • Are you sure your URL is valid/can be accessed by telegram from the web? I cant access it myself Commented Feb 5, 2017 at 6:02
  • yes i can access,185.126.201.42/iisstart.png i mistake the up address Commented Feb 5, 2017 at 6:07
  • So the url you're using in your code that gives you that error message, is actually 185.126.201.42/iisstart.png? Commented Feb 5, 2017 at 6:08
  • @JemarJones this codeshare.io/5X84p8 my code Commented Feb 5, 2017 at 6:12
  • @JemarJones what happen? Commented Feb 5, 2017 at 6:23

2 Answers 2

2

The problem can be originated from the following issues:

  • the image file extension is not allowed by the telegram.
  • file size is larger than that allowed by the telegram.

You can start with the former one.

Sign up to request clarification or add additional context in comments.

Comments

0

Accoding to example you can sendPhoto:

await Bot.SendChatActionAsync(message.Chat.Id, ChatAction.UploadPhoto);

            const string file = @"<FilePath>";

            var fileName = file.Split('\\').Last();

            using (var fileStream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                var fts = new FileToSend(fileName, fileStream);

                await Bot.SendPhotoAsync(message.Chat.Id, fts, "Nice Picture");
            }

Documentation: https://mrroundrobin.github.io/telegram.bot/html/M_Telegram_Bot_TelegramBotClient_SendPhotoAsync_3.htm

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.