Error creating users via the web service

Error creating users via the web service

by Xollie Mdlalose -
Number of replies: 0

Hi,

I am new to moodle and I am struggling to create 100 users via the core user create users api using php

I am able to create 7 or less users but once I push 20 or more i get an error message of which I think its because of the Rest maximum URL lengthsad

How can I solve this, please see my code snippet below

$tokenurl = 'http://myserver/login/token.php?username=admin&password=Admin&service=Students';


$tokenresponse = file_get_contents($tokenurl);


$tokenobject = json_decode($tokenresponse);


if (!empty($tokenobject->error)) {

    echo $tokenobject->error;

    die();

}


$users = array(array($BulkUserImport)); //BulkUserImport is an array containing 100 students 


$params = array(

    'wstoken' => $tokenobject->token,

    'wsfunction' => 'core_user_create_users',

    'moodlewsrestformat' => 'json',

    'users' => $users,

);

Average of ratings: -