Views Services ( webservice desde reporteador Y EJEMPLOS)

Utiliza el modulo  drupal de views_services en Version: superior a 7.x-1.2


Para crear un nuevo webservice/api basado en una vista:

  1. Crear display tipo service
  2. configurar la vista con las variables/campos requeridos 
  3. si requiere variables de entrada configurarlas en  FILTER CRITERIA asignando las valiables dentro de cada filtro en "Filter identifier"
  4. Si el campo es obligatorio  en "EXPOSED FORM"  dejar Exposed form style:Input required  y en la variable dar campo exijido
  5. Dar permisos en SERVICES 
  6. Acceder como<endpoint path>/views/<view machine name>?display_id=<display_id>&varible1=xyz&variable2=abcd

<endpoint path> : Creado en estructura > services. Deben darse ltambien os permisos para acceder al servicio en el "resource" del webservice creado.
<view machine name> : verla en el url 
display_id : nombre de maquina del display  en views



Drupal Services Examples

tyler's picture

Submitted by tyler on Fri, 10/28/2011 - 09:55

Updated: 2017-05-04





planet drupal

drupal 7.x

jDrupal: Be sure to check out jDrupal for an easy to use JavaScript Library to communicate with Drupal Services.

This document describes how to read/write entities to/from Drupal using the Services module. It also covers how to handle session authentication. Let's get started...

Installation and Setup

  1. Download the Services Module
  2. Enable It
  3. Drink Dr. Pepper

Now to create a service, we'll start with the basics... go to Structure -> Services -> Add, and enter some stuff like this:

Name my_services
Endpoint title My Services
Server REST
Path to endpoint my_endpoint

Ignore the other fields for now. Click 'Save' to, you guessed it, save your new service.

Next up, we need to enable some Resources for our Service. Go to Site Structure -> Services -> List, then click 'Edit Resources' next to your Service.

Check the boxes next to each resource that you'd like to enable, save, then flush all of Drupal's caches.


Each example below includes the HTTP method (GET, POST, PUT, or DELETE) and an example URL to use. When using POST or PUT, you must send along some data, and that example data will be listed on the line after the http method and url. If there is a special Content-Type header to use, it will be mentioned after the data, otherwise just use application/json.

C.R.U.D.I. = Create, Retrieve, Update, Delete, Index


For all POST, PUT and DELETE requests (except for user login), you must attach a token to the header of your request. The name of the header to use is:


The value of the token can be retrieved here:



Unless otherwise noted, the Content-Type header of your request should be set to:


Session Authentication

GET: http://localhost/drupal-7/?q=services/session/token

POST: http://localhost/drupal-7/?q=my_endpoint/system/connect.json

POST: http://localhost/drupal-7/?q=my_endpoint/user/login.json
POST: http://localhost/drupal-7/?q=my_endpoint/user/logout.json

POST: http://localhost/drupal-7/?q=my_endpoint/user/register.json

User C.R.U.D.I.

POST: http://localhost/drupal-7/?q=my_endpoint/user.json

GET: http://localhost/drupal-7/?q=my_endpoint/user/52.json

PUT: http://localhost/drupal-7/?q=my_endpoint/user/52.json

DELETE: http://localhost/drupal-7/?q=my_endpoint/user/52.json

GET: http://localhost/drupal-7/?q=my_endpoint/user.json

Node C.R.U.D.I.

POST: http://localhost/drupal-7/?q=my_endpoint/node.json

GET: http://localhost/drupal-7/?q=my_endpoint/node/125.json

PUT: http://localhost/drupal-7/?q=my_endpoint/node/125.json

DELETE: http://localhost/drupal-7/?q=my_endpoint/node/125.json

GET: http://localhost/drupal-7/?q=my_endpoint/node.json

Comment C.R.U.D.I.

POST: http://localhost/drupal-7/?q=my_endpoint/comment.json

GET: http://localhost/drupal-7/?q=my_endpoint/comment/30.json

PUT: http://localhost/drupal-7/?q=my_endpoint/comment/30.json

DELETE: http://localhost/drupal-7/?q=my_endpoint/comment/30.json

GET: http://localhost/drupal-7/?q=my_endpoint/comment.json&parameters[cid]=30

Taxonomy Vocabulary C.R.U.D.I.

POST: http://localhost/drupal-7/?q=my_endpoint/taxonomy_vocabulary.json

GET: http://localhost/drupal-7/?q=my_endpoint/taxonomy_vocabulary/16.json

PUT: http://localhost/drupal-7/?q=my_endpoint/taxonomy_vocabulary/16.json

DELETE: http://localhost/drupal-7/?q=my_endpoint/taxonomy_vocabulary/16.json

GET: http://localhost/drupal-7/?q=my_endpoint/taxonomy_vocabulary.json&parameters[name]=WkSTeYfABe

Taxonomy Term C.R.U.D.I.

POST: http://localhost/drupal-7/?q=my_endpoint/taxonomy_term.json

GET: http://localhost/drupal-7/?q=my_endpoint/taxonomy_term/13.json

PUT: http://localhost/drupal-7/?q=my_endpoint/taxonomy_term/13.json

DELETE: http://localhost/drupal-7/?q=my_endpoint/taxonomy_term/13.json

GET: http://localhost/drupal-7/?q=my_endpoint/taxonomy_term.json&parameters[vid]=17&parameters[name]=V8m22sqRBO