Just asking for a bit more documentation. So far I think it's limited to a README file with "Drupal module making it possible to expose Views from Views.module through Service.module's API:s"

Comments

frazras’s picture

Im not sure how to write "official documentation" but the general way this module operates is as such:

  • Download, Install and enable the module as usual
  • Create a service endpoint as per usual (see services documentation)
  • When editing the service, edit the resources
  • Under the resources, you should see views, enable views
  • Now go to YOUR_ENDPOINT/views/VIEWNAME.FORMAT where FORMAT is xml or json or jsonp etc
  • Access your feed to your hearts desire
mgifford’s picture

Adding that to the README file would be a good start. There's often a way for families of modules to do documentation that is consistent enough. Search does a reasonable job - http://drupal.org/project/services_search

there's also http://drupal.org/documentation/modules/services

All this stuff helps get folks started. Possible examples are often cool too. Especially based off of default Views..

jefflinwood’s picture

There isn't any documentation for Services_Views - I'd be happy to help with this, here is a brief outline of what I would put into it

* What it does
* Prerequisites
* Configuring with an endpoint
* Basic Usage
* Arguments and Parameters to Views (limit, offset, args, display_id)

Does someone have a quick example of arguments and parameters that works using the REST Server and Services_Views?

Alex Andrascu’s picture

Very interested in #3 aswell

7wonders’s picture

Status: Needs work » Active

I havent had any need for passing in filters so if anyone knows how, please add.

* What it does

services_views in combination with the Services module version 3.x and later allows you to access and retrieve views via a service endpoint.

* Prerequisites

Services module version 3.x and later is a dependency and you should read up about the different service callbacks available from that module and how to set up endpoints and resources.

* Configuring with an endpoint

Once you have an endpoint set up, visit the resources section of the endpoint and enable the views resource.

* Basic Usage

The most basic usage is http://example.com/my_endpoint/views/view_name which will retrieve the whole view.

A useful tool in firefox for testing services in general is the HttpRequester addon that lets you do all sorts of CRUD.

A basic example in HttpRequester

1.
* URL: http://example.com/my_endpoint/user/login
* Content type: application/json
* Content box: {"username":"blah","password":"blahblah"}
* Click post.

You should get a 200 ok reponse. You are now logged in.

2. 
* URL: http://example.com/my_endpoint/views/view_name
* Click get.

You should get a 200 ok response and a nice big blob of json containing your view.

* Arguments and Parameters to Views (limit, offset, args, display_id)

Based on the full details in the module:

services_views_retrieve($view_name, $display_id = 'default', $args = array(), $offset = 0, $limit = 10, $return_type = FALSE, $filters = array())

/**
* Callback for retrieving views resources.
*
* @param $view_name
*   String. The views name.
* @param $display_id
*   String (optional). The views display name.
* @param $offset
*   Integer (optional). An offset integer for paging.
* @param $limit
*   Integer (optional). A limit integer for paging.
* @param $args
*   Array (optional). A list of arguments to pass to the view.
* @param $return_type
*   String (optional). Whether to return the raw data results (FALSE), the entire views object ('view') or themed results ('theme').
* @param $args
*   Array (optional). A list of exposed filters to pass to the view.
*
* @return
*  Array. The views return.
*/

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
7wonders’s picture

Status: Active » Needs work
mototribe’s picture

great documentation, thank you!!!

Shouldn't the urls end in view_name.json instead of view_name ?

7wonders’s picture

Just view_name seems to work fine for me.

kerberos’s picture

.json is only needed it you want a JSON response. Many other formats are possible (depending on your server settings) and the default is XML if there is no extension. Alternatively you can specify the format through the request rather than the URL.

-Daniel
Dragonvale Breeding Guide

kylebrowning’s picture

Dont forget you can pass Accept: application/json headers as well, if you dont want to sue the extension

kerberos’s picture

I just edit my answer to include that and then I saw your post. Sorry. :)

-Daniel

Jānis Bebrītis’s picture

in addition to #5

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
7wonders’s picture

Status: Active » Needs work

Added Janis' feedback to the above post so its easier to copy paste when its added as a readme.txt.

ygerasimov’s picture

Status: Needs work » Fixed

I have updated documentation. Both project page and README file. Should you have any questions please open new issues.

tinflute’s picture

this documentation has not yet made it into the 6.x README

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Jānis Bebrītis’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Closed (fixed) » Needs work

Can you add this to 6x branch too, please?

ygerasimov’s picture

Janis, I am not quite in position to maintain 6.x branch. I would really appreciate if you can advise what text for documentation I should place for 6.x branch so I will commit it. Thank you.

tinflute’s picture

The readme for 6.x should contain quoted text from #5 and #12 above, cut and paste.

ygerasimov’s picture

Status: Needs work » Fixed

Fixed. Thank you.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.