I created a custom service with mymodule_services_resources and I'm calling a function to return some items. This function inside is calling a view with views_get_view. The problem is always return an empty array.

If tested the same code somewhere else it shows the right results, but it does not work with services. I have something like this:

$view = views_get_view('the_view');
$args = array("my_param");
$view->result; //empty array in the WS  

I tried loading the admin user ($user = user_load(1); ) before calling the view but I had the same results.

Is there something I should add, change or remove in order I can get the results of a view calling service endpoint?


  • 1
    Try views_get_view_results('the_view', 'default', 'my_param'); instead, or use the Views datasource's sub module called Views JSON. Nov 19, 2015 at 4:04

1 Answer 1


the module services_views will help you expose the view as a resource in two different ways

It has currently two features:

  • Create view based resource creating Services display in a view
  • Execute any view of the system via views resource call

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.