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

Hi i am trying to understand how Open EMR API works, so i try to register a new App in the demo site, But after i submit i get this error “JSON.parse: unexpected character at line 1 column 1 of the JSON data”. this also happened to me on my dev site.

Demo site i used: https://seven.openemr.io/a/openemr
Details i used to register a new app:
App Redirect URI: Swagger UI
App Launch URI:Swagger UI: OAuth2 Redirect

JSON Web Key Set URI: https://seven.openemr.io

When i submit i get this error : JSON.parse: unexpected character at line 1 column 1 of the JSON data

Thanks
Casper

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

means that the server is responding with something that is NOT JSON, but the browser (or JavaScript) is trying to parse it as JSON.

:white_check_mark: ROOT CAUSE IN YOUR CASE:

You’re using invalid entries for App Redirect URI and App Launch URI:

You entered:

App Redirect URI: Swagger UI

App Launch URI: Swagger UI: OAuth2 Redirect

These are not valid URLs, so when OpenEMR tries to process and return a response, it either:

Fails internally and returns an HTML/PHP error

Or outputs blank/HTML instead of JSON

:white_check_mark: THE FIX: Use Valid URLs (Demo Site)

Here is the correct way to fill out the form when registering an app for testing on the OpenEMR demo site https://seven.openemr.io:

Field

Correct Value

App Name

Swagger Test App

App Redirect URI

https://seven.openemr.io/swagger/oauth2-redirect.html

App Launch URI

https://seven.openemr.io/swagger/index.html

JSON Web Key URI

(Leave blank) unless you know what you’re doing with JWT keysets

App Type

Public or Confidential depending on if you want client_secret or not

Grant Type

authorization_code

Then submit the form.

:white_check_mark: How to Confirm It Works

Once submitted successfully:

Open Swagger UI at
https://seven.openemr.io/swagger/

Click “Authorize” (top-right lock icon)

Use your client ID (retrieved from DB or form) and try the OAuth2 flow

:hammer_and_wrench: STILL GETTING THE ERROR?

Here’s how to debug it further:

Option 1: Browser Dev Tools

Press F12 → Go to Network Tab

Click the request for the form submit

Look at the Response tab

If it’s HTML, it’s a PHP error (e.g. Fatal error, undefined index, etc.)

If it’s blank, OpenEMR may have silently failed

Option 2: Check PHP Logs (on your dev site)

Check your file:

/var/log/php_error.log

Or OpenEMR’s log:

sites/default/logs/php_error.log

:white_check_mark: Summary

:white_check_mark: Don’t use plain words like “Swagger UI” in URI fields
:white_check_mark: Use valid HTTPS URLs (e.g. the Swagger redirect page)
:white_check_mark: Check Network & PHP logs if errors persist
:white_check_mark: Use:

Redirect URI → https://seven.openemr.io/swagger/oauth2-redirect.html

Launch URI → https://seven.openemr.io/swagger/index.html

Let me know if you want a working demo or want to register it via the database directly. I can help with that too. It will work