If I set the user_id and the message text, then everything works fine print(vk.messages.send(user_id = 'Здесь id',random_id= "" ,message="Здесь текст"))

If I set the user_id and the message text via a variable, it gives an error

 vk_session = vk_api.VkApi('Логин', 'пароль') vk_session.auth() vk = vk_session.get_api() def sendmessages(usid,textsend): print(vk.messages.send(user_id = 'usid',random_id= "" ,message="textsend")) commands00 = input() usid = input('Укажите id:') textsend = input('Укажите текст сообщения:') if commands00 == ('send'): sendmessages(usid,textsend) 

vk_api.exceptions.ApiError: [100] not integer

It says that user_id не целое число , I do not understand what the catch is if you set the text in the text editor id and the text is ok, but if through a variable, then an error.

    1 answer 1

    First, here you do not set the value of the user_id parameter through a variable, but pass the string "usid" to the parameter

     vk.messages.send(user_id='usid', random_id='', message='textsend') 

    Fix on

     vk.messages.send(user_id=usid, random_id='', message=textsend) 

    Second, the input function returns a string. If you need a number, then the returned value must be converted:

     sendmessages(int(usid), textsend) 

    PS Follow the PEP-8 .