TelegramBots / Telegram.Bot.Examples

Examples for the Telegram.Bot C# Library
MIT License
639 stars 294 forks source link

Upload #74

Closed shahinesi closed 6 years ago

shahinesi commented 7 years ago

Hi i want upload pic from my own folder asp.net but error plz help me Upload code `using (FileStream fs = System.IO.File.Open(@"|DataDirectory|\App_Data\p1.jpg", FileMode.Open)) { var file = new FileToSend("p1.jpg", fs);

                    await bot.SendPhotoAsync(ChatID, file);
                }`

and error 108 bytes application/json; charset=utf-8 { "Message": "An error has occurred.", "ExceptionMessage": "Bad Request: wrong file identifier/HTTP URL specified", "ExceptionType": "Telegram.Bot.Exceptions.ApiRequestException", "StackTrace": " at Telegram.Bot.TelegramBotClient.<SendWebRequestAsync>d__1251.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)\r\n at GifBot.Controllers.WebhookController.d3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Threading.Tasks.TaskHelpersExtensions.d31.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()" }

karb0f0s commented 6 years ago

@shahinesi please check our test for working example https://github.com/TelegramBots/Telegram.Bot/blob/ce94da88aecb870b7e7a263d2f0e50da82beaba0/test/Telegram.Bot.Tests.Integ/Sending%20Messages/SendingPhotoMessageTests.cs#L36-L45

you can discuss this question in our group chat