title: Create user using Moodle webservice
body: <p>I have tried to create a new user on the Moodle by web service api.</p>
  
  <p>I tried with a <a href="https://github.com/moodlehq/sample-ws-clients/blob/master/PHP-REST/client.php" rel="nofollow">example</a> that i found on the github and with another php code</p>
  
  <p>In the both i receive the same response:</p>
  
  <p><strong>"Missing required key in single structure: users"</strong></p>
  
  <p>the response:</p>
  
  <pre class="lang-php prettyprint-override"><code>{
      "exception":"invalid_parameter_exception",
      "errorcode":"invalidparameter",
      "message":"Invalid parameter value detected",
      "debuginfo":"Missing required key in single structure: users"
  }
  </code></pre>
  
  <p>I try to change the object by a array, but the error continues.</p>
  
  <p>my code:</p>
  
  <pre class="lang-php prettyprint-override"><code>$functionname = 'core_user_create_users';
  $user1 = new stdClass();
  $user1-&gt;id = 1;
  $user1-&gt;username = 'testusername1';
  $user1-&gt;password = 'testpassword1';
  $user1-&gt;firstname = 'testfirstname1';
  $user1-&gt;lastname = 'testlastname1';
  $user1-&gt;email = 'testemail1@moodle.com';
  $user1-&gt;auth = 'manual';
  $user1-&gt;idnumber = 'testidnumber1';
  $user1-&gt;description = 'Hello World!';
  $user1-&gt;city = 'testcity1';
  $user1-&gt;country = 'BR';
  
  
  
  $token = 'mytoken';
  $domainname = 'localhost/moodle';
  $functionname = 'core_user_create_users';
  $restformat = 'json';
  $serverurl = $domainname . '/webservice/rest/server.php'. '?wstoken=' . $token . '&amp;wsfunction='.$functionname.'&amp;moodlewsrestformat=' . $restformat;
  
  $users = array($user1);
  $params = array('users' =&gt; $users); 
  
  $context = stream_context_create(array(
      'http' =&gt; array(
          'method' =&gt; 'POST',                    
          'header' =&gt; 'Content-Type: text/plain',
          'content' =&gt; $params                             
      )
  ));
  
  $contents = file_get_contents($serverurl, null, $context);            
  
  //print_r($contents);
  
  $resposta = json_decode($contents);  
  </code></pre>
  
  <p>I have a valid token and the user is allowed to use the <code>core_user_create_users</code> function</p>