Quantcast
Viewing all articles
Browse latest Browse all 426

DrupalGap Troubleshooting

DrupalGap Module Installation Troubleshooting

When DrupalGap is enabled, it automatically creates a Service Endpoint and enables a few Service Resources. Let's verify these were automatically setup correctly.

1. Service Endpoint - Visit admin/structure/services and verify the 'drupalgap' Endpoint is listed in the table, and verify it is enabled.

2. Service Endpoint Settings - Visit admin/structure/services/list/drupalgap and verify the following settings:

  • Server: REST
  • Path to endpoint: drupalgap
  • Debug mode enabled: optional
  • Session authentication: checked

3. Service Resources - Visit admin/structure/services/list/drupalgap/resources and verify all drupalgap_* Resources are enabled.

4. REST Server - Visit admin/structure/services/list/drupalgap/server and verify these settings are enabled:

Response formatters:

  • json

Request parsing:

  • application/json
  • application/x-www-form-urlencoded
  • multipart/form-data

5. The SPYC dependancy for the Rest Server has some known issues.

Manually Confirm Services Are Set Up Properly With The Firefox Poster Plugin

If visiting admin/config/drupalgap throws an error, and the trouble shooting topics above do not work, then as a last resort, we can use the Firefox Poster Plugin to make sure the DrupalGap Service Endpoint is set up properly.

Open up the Poster plugin for Firefox when you are NOT LOGGED INTO your Drupal site:

Once you fill out the 'URL' and 'Content Type' fields, click the 'POST' button in the 'Actions' section. A Response window with a status of '200 OK' should show up if everything worked correctly. You should get a JSON response similar to the following:

{
    "sessid":"abcdefghijklmnopqrstuvwxy",
    "user":{
        "uid":0,
        "hostname":"127.0.0.1",
        "roles":{
            "1":"anonymous user"
        },
        "cache":0,
        "session":"",
        "timestamp":"1321994670"
    }
}

As you can see, the System Connect resource returns JSON with some information about the currently connected user.

Developing with Localhost Drupal & Android Emulators

If you are developing on localhost and want your mobile application to communicate with your Drupal install, you may need to use 10.0.2.2 instead of localhost inside DrupalGap, for example:

http://localhost/my_drupal_site ==> http://10.0.2.2/my_drupal_site

[phonegap]/www/index.html

Make sure the www/index.html file in PhoneGap is pointing to the correct version of the Cordova JS file.

Common Error Messages

Error: "Not found: Could not find the controller."

If you receive this error, this means one of two things

  1. The Service Resource is not Enabled for Your Service Endpoint (admin/structure/services)
  2. Your HTTP Method for Accessing the Service Resource is Incorrect. (GET, POST, PUT, DELETE)

DrupalGap API Error

  • parsererror (SyntaxError: Unable to parse JSON string) [OK] - Disable the "Views API Mode" under "Settings" in the "Format" section for your "JSON Data Document" view (views datasource, views json).

CSRF Validation

Since Services 3.4, all method calls to Service Resources via POST, PUT and DELETE now need a valid session token to be passed along in the request header. The token can be retrieved by using GET on services/session/token. The token's value must then be passed along in the request header using a key of "X-CSRF-Token". For more information see these links:

Upgrade to the latest recommend release of the DrupalGap module and the mobile application development kit for the fix.


Viewing all articles
Browse latest Browse all 426

Trending Articles