The API keeps returning this error: {'ok': False, 'error_code': 400, 'description': 'Bad Request: BOT_TITLE_INVALID'}
I’ve verified my bot token is correct and tried different approaches like using GET requests with params, but while those return success status, the bot name never actually updates. Same issue happens with setMyDescription and setMyCommands - they report success but no changes occur.
UPDATE: Fixed it! The solution was to pass the parameters directly as json without using json.dumps(). Just use json=bot_data instead of json=json.dumps(bot_data).
Glad you figured it out! I ran into something similar a while back and the culprit was actually the bot name itself. The Telegram API is pretty strict about naming conventions - bot names can’t exceed 64 characters and they need to avoid certain special characters or patterns that might confuse users. I was using underscores and numbers in mine which caused the BOT_TITLE_INVALID error even though the request format was correct. Worth double-checking that your bot name follows their guidelines if anyone else hits this issue. Also noticed you mentioned setMyCommands having the same problem - that one usually works fine with the same json parameter approach once you get the formatting right.
nice catch on the json.dumps issue! had the exact same problem few months ago and was pulling my hair out. telegram’s api can be really picky about how you send the data - sometimes using data= parameter works better than json= depending on the endpoint too. btw make sure your bot name doesnt have any weird unicode characters, that trips up the validation sometimes even if it looks normal
Had this exact same headache with the Telegram Bot API last year. What caught me off guard was that the setMyName method also validates against reserved words and common spam patterns. Even perfectly formatted requests can fail if your chosen name triggers their internal filters. I ended up testing with a completely generic name first just to verify the API call was working, then gradually modified it until I found what was being rejected. Another thing that bit me was trying to update the name too frequently - there’s an undocumented rate limit that can cause temporary failures if you’re testing multiple variations quickly. Your json parameter fix is spot on though, that’s definitely the most common cause of this error.