Skip to content

shakyapranin/webservice

Repository files navigation

Webservice Module 0.1.0

Module that exposes drupal entities to RESTful APIs.

Supports Drupal 7.x

Dependencies

  1. cors module
    cors

Module Usage

  1. Git clone {git_url} or download zip.
  2. Rename 'webservice-master' to 'webservice'.
  3. Copy folder to sites/all/modules.
  4. Enable module.
  5. 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.
  6. Clear drupal cache.

Considerations before using the API

  1. 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'.

API usage

  1. 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}

  2. 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

Additional information for CORS module

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

About

Drupal module to expose drupal entities to RESTful APIs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages