I'm using the following setup.
- Drupal 7.12
- Views 7.x-3.3
- Services 7.x-3.1
- C-tools 7.x-1.0-rc1
- Services Views 7.x-1.x-dev
I setup my endpoint as follows:
name: data
server: REST
path: data
debug mode: enabled
authentication: session
Then, I enabled "views" resource for that endpoint.
With the settings above, I can retrieve an XML or JSON formatted data from my view, with the following URL.
http://example.com/data/views/my_view_name
http://example.com/data/views/my_view_name.json
However, the number of items returned at these URLs are different from the number of items I set the view to display.
In my view, I set the view as follows:
Items per page: 2
Number of pages: 2
Number of pages: 1 (Corrected at 16:39:49 on April 10th, 2012 +0900)
However, both the URLs above return 10 items. Moreover, it is very strange that the URL return just 10 items, while in fact my test site has more than 10 items.
Is there anything I fail to set?
| Comment | File | Size | Author |
|---|
Comments
Comment #1
rahulbile commentedCan you just try calling the URL as :
http://example.com/data/views/my_view_name?display_id=default&limit=10 ? To confirm that it respects the count u ask for ?
Comment #2
aiwata55 commentedrahulbile, thank you for your time and help.
I accessed the following URL, instead, thinking that display_id=default is by default and setting the limit argument to 10 doesn't help to figure out the cause of my problem because I am receiving 10 results.
http://example.com/data/views/clone_of_stat_data_list?display_id=page&limit=0(my view name is
clone_of_stat_data_list)Passed arguments:
Called arguments:
And I received 10 nodes.
The result doesn't change when I set the limit argument to 2. I received 10 items.
Also, here is my setting of

clone_of_stat_data_listview. Please make sure that I told Views to display only 2 items.It seems that my arguments are not passed to Services Views module properly.
Comment #3
rahulbile commentedSeems to be working fine for me.
Comment #4
aiwata55 commentedrahulbile, thanx again for your intent to help.
What do you mean by that?
Could you not reproduce the problem I am facing?
Or, do you think the behavior of my system is proper and as specified?
If the reason of your last comment is the latter one, I don't get it. I set the limit to 0 or whatever, and Services Views returns 10 items no matter when.
Would you elaborate a little more on that?
Comment #5
aiwata55 commentedProblem solved.
It turned out that Clean URL feature on my test server has not been turned on. I didn't question that because I could access pages without "?q=" in the addresses. After enabling Clean URL feature, I could limit the number of the result with "?limit=n" where n should be replaced with the actual number of items you want to get. Also, passing "?limit=0" returns all the items which match the query of the original view.
(Just for other Services Views newbees)
However, the resulting array without the limit argument in the URL has 10 items, if the number of the items which match the query of the original view exceeds 10. For example, if your view displays 5 nodes of page content type on a page and your site has more than 10 page nodes, then Services Views will return 10 items if without the limit argument in the URL. To limit the number of items returned by Services Views to a given number (even if you set the number of items on a page in your view), you MUST use the limit argument in the URL.
Comment #6
aiwata55 commentedClosing the issue.
Comment #6.0
aiwata55 commentedMade correction on "Number of pages".