1

I have a problem when I use the following code:

try
{
    var url = "https://www.telegadmin.com/image/tinakish/qavasi.jpg";
    var uri = new Uri(url);

    using (WebClient webClient = new WebClient())
    {
        using (Stream stream = webClient.OpenRead(uri))
        {
            //bot.SendTextMessageAsync(update.Message.Chat.Id, "تا اینجا اوکیه", replyMarkup: mainMenu);
             bot.SendPhotoAsync(update.Message.Chat.Id, new FileToSend("test.jpg", stream), caption: "این تصویر از سرور برای شما ارسال شده است", replyMarkup: mainMenu);

            return Ok();
        }


    }
    return Ok();

}
catch(Exception ex){
    bot.SendTextMessageAsync(update.Message.Chat.Id,ex.ToString(), replyMarkup: mainMenu);
    return Ok();

}

It's working for me in C#, but does not work in setwebhook. Can you help me?

Pang
  • 9,564
  • 146
  • 81
  • 122

1 Answers1

1

try this:

Bot.SendPhotoAsync(update.Message.Chat.Id, new FileToSend("test.jpeg", stream), caption: "این تصویر از سرور برای شما ارسال شده است", replyMarkup: mainMenu).GetAwaiter().GetResult();

you didn't execute the task.

Mohammad
  • 2,724
  • 6
  • 29
  • 55
  • you are welcome. please consider marking the question as a answer in order to close the topic. thanks – Mohammad Sep 19 '17 at 12:34