Module that exposes drupal entities to RESTful APIs.
- cors module
cors
- Git clone {git_url} or download zip.
- Rename 'webservice-master' to 'webservice'.
- Copy folder to sites/all/modules.
- Enable module.
- Setup CORS module from = admin/config/services/cors
Place 'api/v1/||GET,OPTIONS|Content-Type,Checksum|True' inside Domains field and Save configuration.
The controls can be modified as per need. - Clear drupal cache.
-
By default the checksum header for the APIs are md5 hash of the allowed domain name.
For example : you placed the entry 'api/v1/*|example.com|GET,OPTIONS|Content-Type,Checksum|True' in the Domains field.
Your hash will be : 1a79a4d60de6718e8e5b326e338ae533 i.e. a md5 hass of the domain name 'example'.
-
Access APIs using
GET http://{drupal_instance}/api/v1/content/{bundle_name}
HEADERS 'checksum' = {your_checksum}By default drupal ships with : article and page so the APIs would be
GET http://{drupal_instance}/api/v1/content/article
HEADERS 'checksum' = {your_checksum}GET http://{drupal_instance}/api/v1/content/article/{id}
HEADERS 'checksum' = {your_checksum} -
Offset and limit can be used as
GET http://{drupal_instance}/api/v1/content/article?page={page number}&&limit={numeric value}
HEADERS 'checksum' = {your_checksum}NOTE: To remove any further confusions on checksum refer Consideration before using the API section
A list of paths and corresponding domains to enable for CORS. Multiple entries should be separated by a comma. Enter one value per line separated by a pipe, in this order:
Internal path
Access-Control-Allow-Origin. Use to echo back the Origin header.
Access-Control-Allow-Methods
Access-Control-Allow-Headers
Access-Control-Allow-Credentials
Examples:
|http://example.com
api|http://example.com:8080 http://example.com
api/|,https://example.com
api/*||POST|Content-Type,Authorization|true