Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I retrieve a user using a query string from drupal using REST?
    primarykey
    data
    text
    <h2>What I'd like</h2> <p>I want to be able to reset a users password without emailing them. I also need to do this via REST (it's for a kiosk system).</p> <p>So I need to:</p> <ol> <li>Get user with a specific username</li> <li>Reset the password of that user</li> </ol> <p>Try as I might, I can't get the user with a username.</p> <h2>The problem</h2> <p>After I've logged in using the admin user via REST I do:</p> <p><code>GET on <a href="http://mydomain.com/rest/user?name=user" rel="nofollow">http://mydomain.com/rest/user?name=user</a></code>. </p> <p>According to REST documentation, this should get the user with name <code>user</code>.</p> <p>I get a 200 response, but <strong>nothing is returned in the body</strong>.</p> <h2>What I've Tried</h2> <p><strong>Get node from ID</strong></p> <p>Once I've logged in as admin, I can do:</p> <p>GET on <a href="http://mydomain.com/rest/user/1" rel="nofollow">http://mydomain.com/rest/user/1</a></p> <p>This works, returning the details of user 1 in the response. But I need to search for a user by username.</p> <p><strong>Different GETs</strong></p> <pre><code>GET on http://mydomain.com/rest/user/admin GET on http://mydomain.com/rest/user/account/name/admin GET on http://mydomain.com/rest/user?account[name]=admin GET on http://mydomain.com/rest/user?uid=1 GET on http://mydomain.com/rest/user/retrieve?uid=1 GET on http://mydomain.com/rest/user?account[uid]=1 </code></pre> <p>All these fail.</p> <p><strong>Nodes instead of users</strong></p> <p>GET on <code>http://mydomain.com/rest/node/1</code> works, but <code>http://mydomain.com/rest/node?nid=1</code> gives me a 200 response with nothing in the body.</p> <p><strong>List of all users</strong></p> <p><code>GET on <a href="http://mydomain.com/rest/user/" rel="nofollow">http://mydomain.com/rest/user/</a></code> doesn't show a list of all users either. I get a 200 with empty body again.</p> <h2>Further Details</h2> <ul> <li>I'm working with a Drupal 6.22 install. </li> <li>I've installed the services module (3.0 RC1) and REST Server (2.0 beta 1). </li> <li>I've got the session authentication module installed. </li> <li>I've tried the above with the session authentication switched on and with it off.</li> <li>I've enabled all node resources and user resources for the REST endpoint I've set up.</li> <li>I've tried the above with and without clean URLs and nothing seems to make a difference.</li> </ul> <h2>Question</h2> <p>How do I get a user with a specific username? What am I doing wrong?</p> <h2>Update</h2> <p>I've uninstalled then reinstalled Services module, I've done the same with the REST server. I've also rolled back my version of CTools to the latest recommended one. I've added a brand new service in case it was corrupted. Nothing I do works. Frustrating!</p> <h2>Update 2</h2> <p>I've found the problem, but would like a more permanent solution. It turns out it was an error because of table naming. See my current accepted answer.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload