B
B
bluefasik2021-12-29 12:14:35
Python
bluefasik, 2021-12-29 12:14:35

ApiTelegramException How to solve this problem?

for usl in db.get_hash_data(message.from_user.id):
    adv_link = f"<a href={usl[3]}> Ссылка на объявление</a>"
    bot.send_message(message.chat.id, adv_link, parse_mode= 'HTML')

Gives the following error:
ApiTelegramException("A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: can't parse entities: Unexpected end of name token at byte offset 8")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Skillz01, 2022-01-06
@Skillz01

Here looking what DB you use. If it is MySQL, then it returns the response from the database in the form of a Dictionary {url:www.tvoyurl.com}. In this case, you need to pull out something like

for usl in db.get_hash_data(message.from_user.id):
    adv_link = f"<a href={usl[3]["твой_ключ"]}> Ссылка на объявление</a>"
    bot.send_message(message.chat.id, adv_link, parse_mode= 'HTML')

Where "your_key" is the name of the key from the dictionary you get from the database.
Otherwise, you can just pull out print() usl[3] and see what type of data you get there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question