pengrad / java-telegram-bot-api

Telegram Bot API for Java
https://core.telegram.org/bots
Apache License 2.0
1.81k stars 374 forks source link

Send message to a channel error #10

Closed igoralves98 closed 8 years ago

igoralves98 commented 8 years ago

Hi, first of all thanks for the wonderful API. Second, I'm getting a retrofit.RetrofitError: 400 Bad Request when trying to send a message to a channel using bot.sendMessage("@mychannel", "short message sending");.

pengrad commented 8 years ago

Hi, I think there is something with your channel or bot. If you directly call Telegram API everything is fine? And you are not on Google App Engine?

Anyway, build your bot with TelegramBotAdapter.buildDebug("BOT_TOKEN") and post full log (telegram api answer)

igoralves98 commented 8 years ago

When I call it's everything running ok. I'm running inside my ide (Java Spring Tool Suite) and not using Google app engine.

Here's the debug:

{"ok":true,"result":{"id":95025994,"first_name":"casa258bot","username":"casa258bot"}}
<--- END HTTP (86-byte body)
Usuário: User{id=95025994, first_name='casa258bot', last_name='null', username='casa258bot'}
Is ok? true

---> HTTP POST https://api.telegram.org/xxxxxxx/sendMessage
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Content-Length: 42
chat_id=Casa258&text=short+message+sending
---> END HTTP (42-byte body)
<--- HTTP 400 https://api.telegram.org/xxxxxx/sendMessage (289ms)
: HTTP/1.1 400 Bad Request
Server: nginx/1.9.1
Connection: keep-alive
Content-Length: 82
Date: Tue, 19 Jan 2016 00:02:38 GMT
Content-Type: application/json

{"ok":false,"error_code":400,"description":"[Error]: Bad Request: chat not found"}
<--- END HTTP (82-byte body)
retrofit.RetrofitError: 400 Bad Request
---> HTTP GET https://api.telegram.org/xxxxxxx/getUpdates?offset=2&limit=100&timeout=2
---> END HTTP (no body)
<--- HTTP 200 https://api.telegram.org/xxxxxxxx/getUpdates?offset=2&limit=100&timeout=2 (2453ms)
: HTTP/1.1 200 OK
Strict-Transport-Security: max-age=31536000; includeSubdomains
Server: nginx/1.9.1
Connection: keep-alive
Content-Length: 23
Date: Tue, 19 Jan 2016 00:02:41 GMT
Content-Type: application/json

I omitted my authentication code using xxxxx.

pengrad commented 8 years ago

You should add @ to channel name. @Casa258

fjmontesinos commented 8 years ago

Hi

I´m getting 400 error to. In telegram I added my bot to channel administrators and works perfect!!

Good API

Thanks !

drecchia commented 8 years ago

I got some problems with underline when markdown is active, try disabling markdown.

matata1357 commented 7 years ago

{"ok":false,"error_code":404,"description":"Not Found"}