Example XMLRPC POST for user.register

Last updated on
30 April 2025

Example POST

<?xml version="1.0"?>
<methodCall>
   <methodName>user.register</methodName>
   <params>
     <param>
       <struct>
         <member>
           <name>name</name>
           <value><string>username</string></value>
         </member>
         <member>
           <name>mail</name>
           <value><string>example@example.com</string></value>
         </member>
         <member>
           <name>pass</name>
           <value><string>password</string></value>
         </member>
       </struct>
     </param>
   </params>
</methodCall>

If you want to add roles upon creation, add this in the same request:

  <member>
           <name>roles</name>
            <array>
           <data>
           <value><i4>4</i4></value>
         </data>
         </array>
         </member>

Expected responses

if successful:

200 OK

The body contains the newly created uid.

if unsuccessful:

Response codes:

406 Not Acceptable:
The name is already taken.
406 Not Acceptable:
The email address is already registered.
406 Not Acceptable:
The email address example@example.com is not valid.

Testing the code on your server

  • On your endpoint make sure you enabled the XMLRPC backend and the 'user' resource including the 'register' action.
  • Using one of these tools, POST the code to your resource's URL (http://mydrupalsite/foo/user), with 'content-type' being set to 'text/xml' or 'application/xml'.
  • In case you aliased the 'user' resource, both the POST URL and the <methodName> need to be adapted.
  • As both username and email address are unique, in order to repeat the test, you need to replace these values in the POST code by other test values.

Help improve this page

Page status: Not set

You can: