0

I am using postman. I want to provide the username or a user profile field say roll no and fetch the user's information. What should be the URL.

I am able to fetch the user information when I provide the uid using the following URL :

http://[yourdomain]/[endpoint]/user/[uid]
2

If you want to get the user data by providing username, you can use pass name (username) as a parameter to the service URL like follows

http://example.com/<endpoint path>/user?parameters[name]=krishna

If you want to pass either username or other user profile fields you can achieve that using Services Views module. After installing this module make sure to enable it under service resources list.

Create a view with contextual filter(s)

Executing view via views resource

After enabling "views" resource in your services endpoint you can do GET request to:

http://example.com/<endpoint path>/views/<view name>

This will execute a view and pass results.

Possible arguments: - display_id: views display

  • args: array of view arguments
  • filters: array of view filter values
  • offset: views offset
  • limit: limit views number of results
  • format_output: boolean whether we would like to get themed view or data
7
  • example.com/<endpoint path>/user?parameters[name]=krishna this works ! Dec 10 '15 at 11:22
  • i made a view and added User:Name in contextual filters.So what should be the url now. Dec 10 '15 at 12:17
  • tried few urls. they are not working. please help. Dec 10 '15 at 12:18
  • @TulikaSharma URL would looks like follows- http://example.com/<endpoint path>/views/<view name>/[filter] make sure that you've created services view. Dec 10 '15 at 12:38
  • it gives error 404 not find : Could not find the controller Dec 10 '15 at 13:05
0

Please get the user token with below URL:

http://[yourdomain]/[endpoint]/user/token (you might need to login first)

Use the token as x-csrf-token with headers with your URL with GET method:

http://[yourdomain]/[endpoint]/user/[uid]

if above is working then you can choose query parameter as below.

http://[yourdomain]/[endpoint]/user?name=kalpan

4
  • 1
    I think this doesn't provide an answer to the question. OP wants to get the user information by providing username or user profile field. Dec 10 '15 at 8:46
  • Sure, i have updated my answer.
    – Kalpan
    Dec 10 '15 at 8:55
  • I think by providing ?name doesn't gives the result. It returns all the users instead Dec 10 '15 at 8:57
  • yes it provides all the users. doesnt work. Dec 10 '15 at 9:00

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.