Skip to main content
Version: 1.x

API04003: Malformed JSON Response

What This Means​

The server returned data that appears to be JSON but is corrupted or invalid. The POS couldn't parse the response because the JSON syntax is broken.

Common Causes​

  • PHP notices/warnings — PHP output before the JSON
  • BOM (Byte Order Mark) — Invisible characters at file start
  • Encoding issues — Character encoding problems
  • Truncated response — Response cut off mid-transmission
  • Plugin output — A plugin added non-JSON content

How to Fix​

1. Check for PHP Notices​

PHP notices/warnings before JSON break parsing:

In wp-config.php:

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

Review wp-content/debug.log and fix any issues.

2. Check for BOM Characters​

Some text editors add invisible BOM characters:

  • Re-save PHP files without BOM
  • Use UTF-8 without BOM encoding
  • Check recently edited files

3. Verify Complete Response​

If responses are being truncated:

  • Check PHP output buffering settings
  • Increase output_buffering in php.ini
  • Check for timeout issues

4. Test API Directly​

In your browser or using curl:

curl -v https://yoursite.com/wp-json/wcpos/v1/

Look for any unexpected content before the JSON.

5. Check Character Encoding​

Ensure database and PHP use UTF-8:

  • Check wp-config.php charset settings
  • Verify database tables are UTF-8
  • Look for special characters causing issues