Case A: If I create a "Services" display, and set the path option to create a resource. The output will be available at http://example.com/<endpoint path>/<resource name>

Case B: Also, after enabling "views" resource in your services endpoint I can do GET request to: http://example.com/<endpoint path>/views/<view name>

But the two outputs are different from each other. Why is this the case? Some fields appear blank and have unexpected values. I've pasted the output of the two cases below.

Case A Output: http://pastebin.com/FZ1NK12x
Case B Output: http://pastebin.com/jpRXNdbv

Comments

ygerasimov’s picture

Category: bug » support

Case A and Case B are not related to each other. There is no connection between them and outputs should not be the same.

Please advise what values are "unexpected" so I will understand whether it is bug or not.

dayson’s picture

Look at the values of  "project_description": "",  "project_thumbnail": "" in case B, they are blank!

This makes the views/ endpoint useless as I can't get any data besides nid, title in the raw format. This used to work previously. Hope this brings more clarity?

Darren Shelley’s picture

Issue summary: View changes

For anyone else finding this issue:

If you are experiencing a difference between the "views" resource and the "services" display you will most likely need to stipulate the display_id.

e.g in Daysons example:
http://example.com/<endpoint path>/views/<view name>?display_id=services_1

By default if you do not specify a display_id, the master display will be loaded which may not in this case use the same logic to fill out "project_description" and "project_thumbnail".

generalredneck’s picture

Issue summary: View changes
StatusFileSize
new170.26 KB
new178.57 KB

While working on #2900460: Make the Views Resource enforce better security practices.. I have found that this is actually true in regards to the output of the property labels. I have a view that shows title and nid.

If I create a services display, and forgo setting the labels... I get "title" and "nid" as the proprieties.
If I access that same display via the views resource, I get "node_title" and "nid" as the properties.

You can see the output here:

The view looks like this:

$view = new view();
$view->name = 'services_views_sorted_nodes';
$view->description = 'Test View for Services Views';
$view->tag = 'testing';
$view->base_table = 'node';
$view->human_name = 'Services Views Sorted Nodes';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Sorted Nodes';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '5';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
$handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['title']['link_to_node'] = FALSE;
/* Field: Content: Nid */
$handler->display->display_options['fields']['nid']['id'] = 'nid';
$handler->display->display_options['fields']['nid']['table'] = 'node';
$handler->display->display_options['fields']['nid']['field'] = 'nid';
$handler->display->display_options['fields']['nid']['label'] = '';
$handler->display->display_options['fields']['nid']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['nid']['alter']['ellipsis'] = FALSE;
/* Sort criterion: Content: Title */
$handler->display->display_options['sorts']['title']['id'] = 'title';
$handler->display->display_options['sorts']['title']['table'] = 'node';
$handler->display->display_options['sorts']['title']['field'] = 'title';

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['defaults']['access'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['access']['perm'] = 'view own unpublished content';
$handler->display->display_options['path'] = 'sorted-nodes';

/* Display: Services Clone of Page */
$handler = $view->new_display('services', 'Services Clone of Page', 'services_clone_page');
$handler->display->display_options['defaults']['access'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['access']['perm'] = 'view own unpublished content';
$handler->display->display_options['path'] = 'page';

The reason is because for the views resource we go through the whole services_views_retrieve() function before we even talk about displaying the results. In the Service display plugin, we forgo all of that and just display what ever we have. This means that we notice big differences particularly when we use the 'node' row plugin (Render as Content) [which is a whole another issue of why we make an exception for just node] vs fields which we use the "result" row indexes versus the labels that people use for fields. This also means we get a lot more stuff at times because of relationships and stuff.

generalredneck’s picture

Issue summary: View changes