Answer the question
In order to leave comments, you need to log in
How to avoid the "offset should be positive" error when requesting the VK API through stored procedures?
There is such a code here, a little redundant, in order to better understand what is happening.
What is the problem: I call the following procedure, the first thousand user ids come in response (1000 is the maximum that can be obtained through the API), and then this error appears: "One of the parameters specified was missing or invalid: offset should be positive" . That is, offset must be a positive number. The catch is that this very offset (users_got_count variable) does not decrease during the execution of the script, but rather increases (by +1000 per iteration).
var users_got_count = Args.users_got_count; // счетчик добавленных пользователей
var users_total = Args.users_total; // всего пользователей, задается через аргумент, т.к. может измениться
var peeps_left = users_total - users_got_count; // осталось добавить людей
var requests = 0; // сделано запросов
var members;
while (requests < 25 && peeps_left > 0) {
members = members + API.groups.getMembers({"group_id": Args.group_id, "v": "5.44", "offset": users_got_count}).items;
peeps_left = peeps_left - 1000;
users_got_count = users_got_count + 1000;
requests = requests + 1;
}
return members;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question