Closed (works as designed)
Project:
Services
Version:
7.x-3.19
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
9 May 2017 at 12:48 UTC
Updated:
11 Jul 2017 at 17:13 UTC
Jump to comment: Most recent
Comments
Comment #2
nvakenComment #3
tyler.frankenstein commentedIt looks like you may have some bogus entries in your users table. I can see 20 empty results, and 20 results is the default number returned by the entity index resources. I'd dig through your users table to see if there are any bogus rows in the table.
Also, there is no filter on your query string, so that'll always return the first 20 results from the users table. See this issue for advanced filter usage: #2537968: Improve flexibility of entity index resources
Comment #4
nvakenHi tyler.frankenstein! Thanks for the lightning fast response, mucho appreciated.
You might be right that there are bogus entries in there, though, I tried a few others. Would you agree that the following should contain a valid response? I use uid 1 as account to maintain the site all the time and should at least return an e-mailaddress or uid.
http://site.loc/api/user/index?parameters[uid]=1&fields=name,uid&api-key...
Returns:
Comment #5
tyler.frankenstein commented@Ambidex, you're welcome.
Yes, the query string in your above example should return the name and user id for user # 1. Perhaps try temporarily disabling the
api-keyconfig and removing it from the URL to see if that makes a difference. Other than that, I'd first suspect any contrib/custom modules that tinker with Services calls/hooks: http://cgit.drupalcode.org/services/tree/docs/services.alter.api.php?h=7...Then I'd look internally to the Services module to see how/why the results are being assembled/returned that way: http://cgit.drupalcode.org/services/tree/resources/user_resource.inc?h=7...
Comment #6
nvakenI've debugged all the services alter hooks listed in that first link by running `dpm(module_implements('HOOK_NAME'))`. The only hook that is being implemented is `hook_services_request_preprocess_alter` by `services_views` but I cannot imagine that that would be the culprit.
Also, I've checked the `_user_resource_index` function and what it returns. When I check the results of the `services_resource_build_index_list($results, 'user', 'uid');` function, I get back a decent list of user objects with all their properties, so, I'm still a bit in the dark about what's going on...
Comment #7
nvakenComment #8
tyler.frankenstein commentedTry this URL:
http://site.loc/api/user?fields=name,uid&api-key=API-KEY
Instead of this URL:
http://site.loc/api/user/index?fields=name,uid&api-key=API-KEY
And if you're looking for JSON output, I'd recommend replacing "user" with "user.json" in the URL.
Comment #9
nvakenWoah, I had just tracked this thing down to the Spyc::YAMLDump($data); line in ServicesFormatter.inc in which $data goes in with the correct results but the results that Spyc::YAMLDump() returns is the above output. So, it seems that Spyc is not able to process the data?
Your JSON suggestion above is also a life saver, because, when using `user.json` the output seems to be just fine! Does this mean the Spyc implementation is broken? I do not have any experience with the Spyc library.
Comment #10
tyler.frankenstein commentedI never quite figured out what SPYC was for, and I've successfully used the .json extension for years now and have never worried about what SPYC is up to, I think it may be for other formats, xml, etc.
I'm assuming the .json has solved your problem, so I'll go ahead and close this, re-open if need be, thanks for the follow up.
Comment #11
nvakenSpyc is used for YAML formatting. I'm not really sure if it didn't work because of environmental issues or if it's Services implementation is flawed, in the latter it would mean that this is a bug within Segices and this issue might need to be reopened. But I guess it's good for now, my single occurrence of this issue does not prove a pattern.
For my case, I'm happy with the .json format and I'll leave this issue closed. 😉 Thanks for the help!