DrupalGap Troubleshooting

Last updated on
30 April 2025

Is your Drupal site up to date?

First and foremost, it is very important that you are running the latest version of Drupal Core and have the most recent updates to all of your contributed modules. To easily update your Drupal site, it is highly recommended that you use Drush. Otherwise, please refer to https://drupal.org/upgrade for more information.

Troubleshooting Topics on drupalgap.org

http://www.drupalgap.org/troubleshoot

Conflicting Modules

There are a few modules known to having conflicting problems with DrupalGap:

Boost

With Boost, it is possible to disregard requests from DrupalGap. Go to:

admin/config/system/boost

Under the 'BOOST CACHEABILITY SETTINGS' select the 'All pages except those listed' radio button, then add this line to the textarea:

drupalgap/*

Global Redirect

Go to admin/config/system/globalredirect and disable the 'Non-clean to Clean' checkbox.

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. (Drupal 6 Only) - 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/services/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 authenticated calls to Service Resources via POST, PUT and DELETE methods 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.

CSRF Validation with PhoneGap Build

When using PhoneGap Build with iOS, you need to set the access control in your config.xml file, for example:

<access origin="http://www.example.com" />

This should be the same value as the Drupal.site_path variable in your app's settings.js file.

SyntaxError: Unexpected token <

This error can happen at many times for many different reasons. As they are uncovered, the symptoms and solutions will be listed here. Please read these logs for more details:

Other possible reasons:

  • If you're trying to retrieve Views JSON (via Views Datasource), make sure you unchecked the "Views API mode" checkbox in the "settings" for "JSON data document" on your view's admin UI (e.g. admin/structure/views/view/frontpage)
  • After making a Services call, if the website returns html instead of application/json, the response will not be parsed properly. This usually means your Drupal site has a PHP error during the request/response. Check the console.log() messages in your app to debug.

Help improve this page

Page status: Not set

You can: