Services Views

Component ID

990842

Component name

Services Views

Component type

module

Maintenance status

Development status

Component security advisory coverage

covered

Downloads

89222

Component created

Component changed

Component body

Message updated December 1st 2017.
There is a Release for 7.x-1.3. Take a look at the 7.x-1.3 Release Notes.
As always please attempt this upgrade on a non-production environment first as if you upgrade directly from 7.x-1.1 to 7.x-1.3, you will find that your services views will most likely be disabled without an automated upgrade due a decision to force developers to make a more secure configuration. See 7.x-1.3's FAQ section


If you haven't done so already, please update your settings of your api endpoints for the views resource before you upgrade to 7.x-1.3. Take a look at 7.x-1.2 Release Notes for information about the recent security update, the actions needed to be performed by you to keep you safe, and the future plans. Also check out #2900460: Make the Views Resource enforce better security practices..

Views support for the Services module version 3.x and later.

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

Demo video http://youtu.be/DZEhJKMeR5w

Create view based resource creating Services display in a view

In any view you can create "Services" display. It has only one option setting -- path. That will be the name of your resource. After enabling that resource you would be able to do call to

http://example.com/<endpoint path>/<resource name>

This will execute a view and output results. You can create exposed filters and pass them to your resource. For example if we created exposed filter "tags" call will be:
http://example.com/<endpoint path>/<resource name>?tags=7

You can also use Services field formatter in a view that allows to retrieve full field properties (like body field will come with format, safe_value etc.).

Executing view via views resource

As of 1.3, you can now only make calls to view displays of the services type for security reasons. See 7.x-1.3 Release Notes.

After enabling "views" resource in your services endpoint you can do GET request to:

http://example.com/<endpoint path>/views/<view machine name>?display_id=<display_id>

This will execute a view and pass results.

Possible arguments:
- display_id: views display
- args: array of view arguments
- filters: array of view filter values
- offset: views offset
- limit: limit views number of results
- format_output: boolean whether we would like to get themed view or data

Example of calls:

http://example.com/rest/views/articles?display_id=services_1&limit=5&offset=2&filters[tags]=5
http://example.com/rest/views/articles?display_id=services_1&filters[tags]=5&format_output=1