如何求解电报API Java API错误404
需要在使用电报API时使用此错误
Error removing old webhook
at org.telegram.telegrambots.util.WebhookUtils.clearWebhook(WebhookUtils.java:112)
.....
Caused by: Error deleting webhook: [404] Not Found
。
的
@Service
public class Test1Api {
@Autowired
public Test1Api(@Value("${bot.username:}") String botUserName, @Value("${bot.token:}") String botToken) {
try {
TelegramBotsApi telegramBotsApi = new TelegramBotsApi(DefaultBotSession.class);
telegramBotsApi.registerBot(new Test1Bot(botUserName, botToken));
} catch (TelegramApiException e) {
e.printStackTrace();
}
}
}
我
public class Test1Bot extends TelegramLongPollingBot {
private final String botUserName;
private final String botToken;
public Test1Bot(String botUserName, String botToken) {
this.botUserName = botUserName;
this.botToken = botToken;
}
@Override
public String getBotUsername() {
return botUserName;
}
@Override
public String getBotToken() {
return botToken;
}
@Override
public void onUpdateReceived(Update update) {
System.out.println(update.getMessage().getText());
System.out.println(update.getMessage().getFrom());
}
帮助 附加在这里 电报中的错误: 我该怎么办?
I need help with this error when working with Telegram API
Error removing old webhook
at org.telegram.telegrambots.util.WebhookUtils.clearWebhook(WebhookUtils.java:112)
.....
Caused by: Error deleting webhook: [404] Not Found
I have created a bot with telegram,
Service class:
@Service
public class Test1Api {
@Autowired
public Test1Api(@Value("${bot.username:}") String botUserName, @Value("${bot.token:}") String botToken) {
try {
TelegramBotsApi telegramBotsApi = new TelegramBotsApi(DefaultBotSession.class);
telegramBotsApi.registerBot(new Test1Bot(botUserName, botToken));
} catch (TelegramApiException e) {
e.printStackTrace();
}
}
}
here is the bot class
public class Test1Bot extends TelegramLongPollingBot {
private final String botUserName;
private final String botToken;
public Test1Bot(String botUserName, String botToken) {
this.botUserName = botUserName;
this.botToken = botToken;
}
@Override
public String getBotUsername() {
return botUserName;
}
@Override
public String getBotToken() {
return botToken;
}
@Override
public void onUpdateReceived(Update update) {
System.out.println(update.getMessage().getText());
System.out.println(update.getMessage().getFrom());
}
When i try to run my code i have an error from telegram
attaching here
The error from telegram:
What can i do to fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保您提供良好的令牌。
您可以通过手动请求Telegram Bot删除Webhook进行检查。
[post] https://api.telegram.org/bot.org/bot
好的,您应该得到回应:
{
“好”:是的,
“结果”:是的,
“描述”:“ Webhook已被删除”
}
然后,您可以确定您的令牌是正确的,但是您将其提供错误。
可以检查您的应用程序。
但是,如果您的响应不同(例如找不到) - 电报令牌存在问题。
Make sure you provide a good token.
You can check it by manually requesting your telegram bot to delete webhook.
[POST] https://api.telegram.org/bot<your_token>/deleteWebhook
If everything is alright you should get as a response:
{
"ok": true,
"result": true,
"description": "Webhook is already deleted"
}
Then you'll be sure that your token is correct but you're providing it wrong.
Maybe check your application.properties
However if your response is different (eg. Not Found) - there's problem with your telegram token.