6

I'm Using Drupal 7, I installed Services module with all the requirements, according to this question and this video.
enter image description here

I'm trying to get all users with Postman where I give my credential, but I'm getting back that I'm an anonymous user.

enter image description here

  1. How do I pass my credentials?
  2. How to add a filter to that call ,for example get all users with specific role?
  • Did you find any solution? – Lucifer Mar 31 '15 at 10:46
  • Yes, wrote my own module – NickF Mar 31 '15 at 13:57
  • Well i also follow this but i unable to login is there any way to do this – Naveen Aug 18 '16 at 10:30
3

You need to make the user login who have the permission to view the list of user details using following Service API

http://yourdomain/endpointname/user/login 

with follwing json data as arguments

{
"username":"username of the user who have the permission to view the users list",
"password":"password which matched with username"
}

After the successful login you need to get the CSRF token which will play the key role in all authenticated request. To get the token call the below mentioned API,

http://yourdomain/endpointname/user/token

You will receive a token, then add the token to your postman header for the key named X_CSRF_TOKEN. Then you can start to make the authenticated requests.

1

As per latest changes... Please follow this thread.

And most important token key should be X-CSRF-Token.

It can be achieved from below URL also.

http://somehost/services/session/token
1

Worth mentioning that now you'd also have to set the following header:

Name     Value
Cookie   [session_name]=[sessid]

You'll be finding the values for session_name and sessid in the login response, right before the token-value for your X-CSRF-Token.

0

If you're looking to list your users you should create a view in drupal and choose the type to display as users. You can't show lists otherwise from the rest api unless you first create a view to display the list. The other points only let you create,edit, or delete them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.