R
R
richardhrm2021-06-23 22:16:43
Python
richardhrm, 2021-06-23 22:16:43

Error vk_api.exceptions.ApiError: [100] One of the parameters specified was missing or invalid: message is empty or invalid?

import vk_api
import time 
token = "5843245b181ae990161384ba1e0008bd13e5b5fe993d51"
user_id = 1 
vk = vk_api.VkApi(token=token).get_api()
f = open("tt.txt", "rt", encoding="utf8")
def captcha_handler(captcha):
    key = input("Enter captcha code {0}: ".format(captcha.get_url())).strip()
    return captcha.try_again(key)

while True:
    try:
        line = f.read()
        time.sleep(1)
        vk.messages.send(
            chat_id=51,
            message=line,
            random_id=0
        )
        f.seek(0)
    except vk_api.exceptions.Captcha as captcha:
        captcha_handler(captcha)

after calling an exception and entering captcha, an error pops up:
Traceback (most recent call last):
File "C:\Users\Rik\Desktop\321.py", line 15, in
vk.messages.send(
File "C:\Users\ Rik\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\vk_api\vk_api.py", line 708, in __call__
return self._vk.method(self._method, kwargs)
File "C:\Users\Rik\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\vk_api\vk_api.py", line 668, in method
raise error
vk_api.exceptions.ApiError: [100] One of the parameters specified was missing or invalid: message is empty or invalid

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alan Gibizov, 2021-06-23
@richardhrm

Make sure before calling the method that the line passed to it as the message parameter is not empty.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question