Debugging API requests

For debugging API requests and responses, Lupus Decoupled Drupal offers integration with REST Log module.

In decoupled scenarios visitors, are making requests to the front-end application, which is itself retrieving data from the back-end. It is helpful to see the form of requests that reached the decoupled back-end and the responses that the back-end provided.

Logged data consists of:

  • Request method
  • Request header
  • Request URI
  • Request cookie
  • Request payload
  • Response status
  • Response header
  • Response body
  • Response time

Usage

Make some requests either to API endpint (/admin/content view provides View API Endpoint operation for nodes that opens their API endpoint directly) or front-end requests and investigate them at /admin/reports/rest_log.

Set up

  • composer require --dev drupal/rest_log
  • drush en lupus_decoupled_api_log

Configuration

REST Log module's default configuration is sufficient but it can be changed at /admin/config/development/logging/rest_log.

Debugging with curl

Sometimes it is useful to trigger Xdebug from the command line. This can be achieved with curl. Authorization can be provided via session cookie with values copied from the authenticated browser session.

Example of such curl request:

curl -k -i -H 'Cookie: SSESS<seesion-name>=<session-cookie-value>;XDEBUG_SESSION=XDEBUG_ECLIPSE;' https://<domain>/<API-endpoint>
Table of Contents