11

I am trying to fetch some views with the services_views module. Sadly enough I keep getting the response: "404: Not found: Display on view my_view_name could not be found".

I am using Views 3 and I defined for test a view with a 'page' display id. (default display id is not a "default" anymore)

I know that I have to pass the display_id argument but simply can't make it work.

Here is the calls I am trying to use:

http://www.mywebsite.com/rest/views/my_view_name.json?display_id="page"
http://www.mywebsite.com/rest/views/my_view_name.json?display_id=page
http://www.mywebsite.com/rest/views/my_view_name.json?parameters[display_id]="page"
http://www.mywebsite.com/rest/views/my_view_name.json?args[display_id]="page"

In the resource definition for the service it is clear that display_id has to be passed as an argument.

'args' => array(
  'view_name' => array(
    'name' => 'view_name',
    'type' => 'string',
    'description' => 'The name of the view to get.',
    'source' => array('path' => '0'),
    'optional' => FALSE,
  ),
  'display_id' => array(
    'name' => 'display_id',
    'type' => 'string',
    'description' => 'The display ID of the view to get.',
    'source' => 'param',
    'optional' => TRUE,
    'default value' => 'default',
  ),...

Is there anyone who managed to make this work?

Thank you.

1

On a Drupal.org issue page for this module, someone suggests the following for the 7.x version.

The arguments are passed in the usual url format, for example:
http://example.com/my_endpoint/views/view_name?display_id=default&args=123&offset=0&limit=10&return_type=FALSE

Multiple arguments can be used like this:
http://example.com/my_endpoint/views/view_name?display_id=default&args[0]=abc&args[1]=123&offset=0&limit=10&return_type=FALSE

I've been trying to get this working on 6.x but haven't succeeded yet.

1

If you have Firefox installed, or Firebug you can look at the HTML source to get the display_id. See this screen shot (and please ignore my page argument!):

1

I faced the same issue with services_views to pass arguments to a view called by services request and I solved it by applying a patch in the module without that it won't work.

Here is a diff patch from my project

diff --git a/sites/all/modules/services_views/services_views.moduleb/sites/all/modules/services_views/services_views.module
index 9ce8080..65dd92e 100755
--- a/sites/all/modules/services_views/services_views.module
+++ b/sites/all/modules/services_views/services_views.module
@@ -182,6 +182,10 @@ function services_views_views_plugins() {
 function services_views_services_request_preprocess_alter($controller, &$args, $options) {
   if (isset($controller['view info'])) {
     array_unshift($args, $controller['view info']);
+    $args[0]['args'] = array();
+     if (!empty($_GET['args'])) {
+       $args[0]['args'] = $_GET['args'];
+     }
   }
 }

diff --git a/sites/all/modules/services_views/services_views.resource.inc b/sites/all/modules/services_views/services_views.resource.inc
index eb9fbb4..aae2975 100755
--- a/sites/all/modules/services_views/services_views.resource.inc
+++ b/sites/all/modules/services_views/services_views.resource.inc
@@ -111,10 +111,11 @@ function services_views_execute_view($view_info, $view = NULL, $display_id = NUL
     $view_name = $view_info['view_name'];
     $display_id = $view_info['display_id'];

-    $args = array();
+    $args = $view_info['args'];

     $view = views_get_view($view_name);
     $view->set_arguments($args);
+    $view->execute_display($display_id, $args);
   }

I don't remember the link to the patch but that may helps see services views args issues

If you created a service display for the view you would see it as a resource it self.enter image description here

Hope that helps

0

Chances are you want display_id=page_1. The display_id parameter must be the internal id of the display. AFAIK the default display always has id 'default'.

The id's of any additional page displays you create are not visible in the Drupal 6 UI, but you can find them out by doing an export on your view and looking at the resulting code.

Each display is created with a call to $view->new_display() where the third parameter is the id (see views_db_object::new_display).

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.