Error parsing json, unexpected character

This article will be useful for administrators of LiveAgent installed on their own servers.

If you encounter the following error

Error parsing JSON: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

it means that instead of JSON response from LiveAgent API, the client application in browser received something that is not JSON. In most cases, it is because the request to API e.g. /api/v3/contacts/ is handled by incorrect index.php file.

If you have mod_rewrite enabled, LiveAgent requests rely on mod_rewrite to process the request URL and /api/v3/contacts/ should be handled by /api/v3/index.php with parameter contacts. However if your mod_rewrite is misconfigured, this request might be handled by the index file in root directory of your installation. Since it doesn't recognize the parameters, it sends as response the customer portal home page HTML. When client application receives the HTML, it fails to process it as it is not a valid JSON format.

To tell mod_rewrite that /api/v3/index.php should handle the request, modify /api/v3/.htaccess and after line

RewriteEngine On

add line 

RewriteBase /api/v3/

This tells the mod_rewrite that all redirects in the file /api/v3/.htaccess should be prepended by /api/v3/ 

×