我正在使用asp .net Core Web API创建Telegram Bot。我有一个奇怪的例外
HttpRequestException:响应状态代码不指示成功:404(未找到)。”
在Startup.cs的Configure方法中
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseMvc();
Bot.GetBotClientAsync().Wait(); // exception here
// AggregateException: One or more errors occurred. (Response status code does not indicate success: 404 (Not Found).)
}
这是Bot.cs中我的GetBotClientAsync()方法
public static async Task<TelegramBotClient> GetBotClientAsync()
{
if (botClient != null)
{
return botClient;
}
commandsList = new List<Command>();
commandsList.Add(new StartCommand());
botClient = new TelegramBotClient(AppSettings.Key);
string hook = string.Format(AppSettings.Url, "api/message/update");
await botClient.SetWebhookAsync(hook); // also exception here
//HttpRequestException: Response status code does not indicate success: 404 (Not Found).
return botClient;
}
我怎么做错了?我该如何解决?