L
L
LikeKey2021-02-25 14:42:30
Java
LikeKey, 2021-02-25 14:42:30

com.vk.api.sdk.exceptions.ApiParamException error. How to decide?

Error code:

spoiler
Exception in thread "main" com.vk.api.sdk.exceptions.ApiParamException: One of the parameters specified was missing or invalid (100): One of the parameters specified was missing or invalid: message_ids is undefined
  at com.vk.api.sdk.exceptions.ExceptionMapper.parseException(ExceptionMapper.java:117)
  at com.vk.api.sdk.client.ApiRequest.executeWithoutRetry(ApiRequest.java:89)
  at com.vk.api.sdk.client.ApiRequest.execute(ApiRequest.java:64)
  at ru.likekey.main.vk.jobs.MessagesJob.<init>(MessagesJob.java:25)
  at ru.likekey.main.Application.initJobs(Application.java:61)
  at ru.likekey.main.Application.init(Application.java:50)
  at ru.likekey.main.Application.main(Application.java:37)

It is clear from the comment that the message_ids parameter (the lastMessageId field) is not defined, but it is defined in theory, the method code:
Integer lastMessageId = 0;

public MessagesJob() throws ClientException, ApiException {
        lastMessageId = DataStorage.getInstance().getInt(LAST_MESSAGE_ID_KEY); //Возвращает последний id сообщения из property файла
        if (lastMessageId == 0) {
            //Ошибка!
            GetByIdResponse getResponse = Application.vk().messages().getById(Application.actor(), lastMessageId).execute();

            if (!getResponse.getItems().isEmpty()) {
                lastMessageId = getResponse.getItems().get(0).getId();
                DataStorage.getInstance().add(LAST_MESSAGE_ID_KEY, String.valueOf(lastMessageId));
            }
        }

        groupId = Application.groupId();
    }

id=0 is written in the property file.

For me, the moment how the program entered if (lastMessageId == 0) and then writes that lastMessageId is not defined is most not clear.

Parameters of the getById method:
getById(com.vk.api.sdk.client.actors.GroupActor actor, Integer... messageIds)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question