Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Session ID?
Where in this method are you sending the session ID? Isn't that required after receiving it from system.connect?
Drupal handles that
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.
Missing required argument username
Services 7.x-3.0-rc5 has an issue and will always say that the call is missing the username parameter.
Kyle committed a fix to the issue in the repository the 9th of August: http://drupalcode.org/project/services.git/commitdiff/94f101b29c9967e8b2...