Last updated November 23, 2013. Created by brantwynn on December 6, 2012.
Edited by Chi, klausi. Log in to edit this page.

RESTWS exposes Drupal resources (e.g. entities) as RESTful web services. The module makes use of the Entity API and the information about entity properties (provided via hook_entity_property_info()) to provide resource representations.

It aims to be fully compliant to the REST principles.

Installing the Module

  • Copy the whole restws directory to your modules directory (e.g. DRUPAL_ROOT/sites/all/modules) and activate the RESTful Web Services module.
  • Use Drush commands: drush dl restws & drush en restws
  • There is no user interface to configure.

Usage / Testing

To obtain the JSON representation of an entity use your browser to visit:<entity type name>/<entity id>.json
For example: or would resolve as a JSON dump to client. There are no "service endpoints" to configure as resources are just available at uniform paths like "node/1", "user/1". One can use a client in the form of a browser plugin to test out the different CRUD functions.


In order to access entities via this interface, permissions must be granted for the desired operation (e.g. "access content" or "create content" for nodes).
Additionally each resource is protected with a RESTWS permission that can be configured at "admin/people/permissions#module-restws".

Additional Resources

Browser Plugins & Software for Testing

Looking for support? Visit the forums, or join #drupal-support in IRC.


I just post a small "how to" on the Restws authentication method in the following issue :
It could be added to the restws_auth_basic readme ?

The preferred authentication methods (for D8) are described here: Note that in Drupal7 a similar POST request has to be made to /user BUT, the form_id for D7 is: "user_login".

We've assumed that the basicauth module and the token were both needed, similar to what teenage explains. However as klausi explains (, that it's in fact not the correct way.

So you either use the base64 method and send credentials on every request. Or you POST once against /user with credentials and catch the cookie. From there you can use the token.

Dear all,

I tried to create new user by sending data from client website to resource website (installed RESTful Web Services and basic auth module), but the result "406 Not Acceptable: Entity property created doesn't support writing". Both (client and resource) are Drupal 7 websites. Here is my code in client site:

= array(
'name' => 'username222',
'pass' => user_password(8),
'init' => '',
'status' => 1,
'mail' => '',
'created' => time(),
'timezone' => variable_get('date_default_timezone', '')
$json = json_encode($user_info);
$result = add_new_entity($json);
add_new_entity($post_data) {
$base_url = 'http://domainname' ;
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookiefile");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookiefile");
curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id());
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_URL, $base_url . '/user/login');
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, "name=restwsuser&pass=password&form_id=user_login");
curl_setopt($ch, CURLOPT_URL, $base_url . '/restws/session/token');
$HTTP_X_CSRF_TOKEN = curl_exec($ch);
$headers[] = 'Content-type: application/json';
$headers[] = 'X-CSRF-Token: ' . $HTTP_X_CSRF_TOKEN;
curl_setopt($ch, CURLOPT_URL$base_url . '/user');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close ($ch);

Anyway, when I tried to create a node (I just change node data structure), it works properly.

So any thing wrong with my above code or user data structure is not correct?

I really appreciate for your help.


Program Developer at Zaman University, Cambodia
HP: (+855) 15 843 149

It's working now, just change user data structure.

= array(
'name' => 'newuser',
'status' => 1,
'mail' => '',

Program Developer at Zaman University, Cambodia
HP: (+855) 15 843 149