How to create View based Resource creating Services display in a View

Preksha Patel's picture

How to create View based Resource creating Services display in a View

Services Views module is very easiest and effective way to make web service in drupal. It creates view based resource to display service output in a view. It executes any view via calling the view resource created by view's service.

Create web service using views by following steps:

1. Download and install Views module (7.x-3.x or later). 

2. Download and install Services module (7.x-3.x or later), enable services and rest_server module.

3. Download and install CTools module.

4. Download and install Services Views module.

5. Under admin -> Structure -> Services, Create Endpoint, enter Endpoint name, select server as REST server, enter Endpoint path and save it.

6. Now edit the Endpoint and under Server tab, select Reponse Formatter and Request Parsing.

7. Create a view:

   - Enter view name lets say it "Services", select show "Content" and type of "your content type" for which content should be displyed, select sorting crieteria as per your requirement.

   - Create a page, enter the path let's say "services_content" that will be your resource under your Endpoint. Now select fileds, filters as per your requirement. 

8. Under admin -> Structure -> Services, Edit your Endpoint and enable the resource created in views.

   Now, you can access resource like:

     http://yoursitename.com/yourEndPointPath/services_content - Here services_content is your resource name i.e. path given in views.

9. You can also create the exposed filters and pass them in resource as a query string. For example, your exposed filter is tag, then you can access the resource like:

   http://yoursitename.com/yourEndPointPath/services_content?tag=5

Cheers!!!