Infiniter
Infiniter

Reputation: 63

Telegram Bot: Wrong response from the webhook: 404 Bad Request

I have my telegram bot deployed on Heroku. Bot used to work fine, but at some point it just stopped sending messages when receiving commands. here is the answer of getWebHookInfo:

{"ok":true,"result":{"url":"https://telegram-rainbow-bot.herokuapp.com:443/api/message/update","has_custom_certificate":false,"pending_update_count":1,"last_error_date":1613676609,"last_error_message":"Wrong response from the webhook: 404 Not Found","max_connections":40,"ip_address":"54.171.62.111"}}

I have no idea what happened. Bot worked as usual, and suddenly that happens. Bot is using port 443 for https requests. Also sometimes logs say "Failed to determine the https port for redirect".

Upvotes: 2

Views: 4755

Answers (2)

Infiniter
Infiniter

Reputation: 63

I managed to fix this issue (although I'm not sure if this is correct way). At first, I had problem with error code 404. This one fixes by adding UseRouting() in Configure method at Startup.cs. Then I had problem with error code 400. This one I fixed by installing Microsoft.AspNetCore.Mvc.NewtonsoftJson nuget package and then I added AddControllers().AddNewtonsoftJson() in ConfigureServices method at Startup.cs. Probably my code wasn't processing JSON from Telegram correctly. Hope it helps to anyone.

Upvotes: 2

arashnz
arashnz

Reputation: 11

Its probably because your page is not found. https://telegram-rainbow-bot.herokuapp.com/api/message/update not found ! so fix this and try to set your webbook again

Upvotes: 0

Related Questions