Search code examples
javatelegramtelegram-bottelegram-api

Caused by: com.fasterxml.jackson.databind.JsonMappingException: Numeric value (5971126049) out of range of int (-2147483648 - 2147483647)


 org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException: Unable to deserialize response
    Caused by: com.fasterxml.jackson.databind.JsonMappingException: Numeric value (5971126049) out of range of int (-2147483648 - 2147483647)
 at [Source: (String)"{"ok":true,"result":{"message_id":268,"from":{"id":5971126049,"is_bot":true,"first_name":"some","username":"some_bot"},"chat":...

((similar questions have not solved my problem)) hi! I am trying to get the response message from a telegram, bot, but it tells me that the id of the bot (mine) cannot be serialized because it should be a long. How could I change it? Where? thanks a lot!

 SendMessage sendMessage = new SendMessage();
    Message message = null;
    if(update.getMessage().getText().equals("/start")) {
        /*
        List<String> initCategories = dataCategories.getInitCategories();
        ReplyKeyboardMarkup replyKeyboardMarkup = new ReplyKeyboardMarkup();
        List <KeyboardRow> keyboardRowList = new ArrayList<>();
        KeyboardRow row;
        for(String ic: initCategories){
            row=new KeyboardRow();
            row.add(ic);
            keyboardRowList.add(row);
        }
        replyKeyboardMarkup.setKeyboard(keyboardRowList);
        sendMessage.setReplyMarkup(replyKeyboardMarkup);
        */
        sendMessage.setText("Hola "+ update.getMessage().getFrom().getFirstName() + " \uD83D\uDE4B\u200D♂️,\n\n" + welcomemessage);

        try {
            sendMessage.setChatId(update.getMessage().getChatId().toString());
            message = execute(sendMessage);
        } catch (TelegramApiException e) {
          e.printStackTrace();
        }
    }
    return message;
}

Solution

  • ok, with implementation group: 'org.telegram', name: 'telegrambots', version: '5.4.0.1' the problem is solved :D.

    thanks still @FedericoklezCulloca and @Turing85