Example POST

<?xml version="1.0"?>
<methodCall>
   <methodName>user.login</methodName>
   <params>
     <param>
        <value><string>username</string></value>
     </param>
    <param>
        <value><string>password</string></value>
     </param>
   </params>
</methodCall>

Expected responses

if successful:

200 OK

The body contains user data and preferences.

if unsuccessful:

Response codes:

401 Unauthorized:
Wrong username or password.
406 Not Acceptable:
Already logged in as some_username

Testing the code on your server

  • On your endpoint make sure you enabled the XMLRPC backend and the 'user' resource including the 'login' action.
  • In the above code, replace username and password by an existing pair of credentials.
  • 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'.
  • If you aliased the 'user' resource, both the POST URL and the <methodName> need to be adapted.

Comments

floridaproject’s picture

Where in this method are you sending the session ID? Isn't that required after receiving it from system.connect?

fuzzy76’s picture

Since the call is done using HTTP I would assume Drupal stores it in a cookie as usual. This requires the client to accept cookies I guess, but I think most clients do that.

ziodave’s picture

Services 7.x-3.0-rc5 has an issue and will always say that the call is missing the username parameter.

<em class="placeholder">ServicesException</em>: Missing required argument username in <em class="placeholder">services_error()</em> (line <em class="placeholder">342</em> of <em class="placeholder">modules/services/services.runtime.inc</em>).

Kyle committed a fix to the issue in the repository the 9th of August: http://drupalcode.org/project/services.git/commitdiff/94f101b29c9967e8b2...