Solutions
Archived

Custom endpoints that worked in previous versions of OpenIDM fail in OpenIDM 4.x

Last updated Jan 5, 2021

The purpose of this article is to provide assistance if you find that previously working custom endpoints fail after upgrading to OpenIDM 4.x with a 200 OK "Malformed JSON: Expected ',' instead of ' '." message.


Archived

This article has been archived and is no longer maintained by ForgeRock.

Symptoms

The following error is shown in the browser when calling the custom endpoint:

{"code":200,"reason":"OK","Malformed JSON: Expected ',' instead of ''."}

Recent Changes

Upgraded to OpenIDM 4.x.

Causes

OpenIDM 4 has been updated to use CREST 3. Specifically, changes introduced by CREST-328 (The REST API should always include _id and _rev regardless of the field filtering) mean that scripts called by custom endpoints must now return a JSON object rather than a string. Any scripts called by custom endpoints that return just a string will fail with this error.

Solution

This issue can be resolved by updating your scripts to return a JSON object instead of a string.

For example, if your script currently has the following return code:

return openidm.decrypt(encrypted);

You can update it as follows:

return { "JSONobjectID" : openidm.decrypt(encrypted) };

When you call the associated custom endpoint, you will see the expected response with an extra "_id" attribute due to these changes, for example:

{ "_id": "", "JSONobjectID": "decryptedOutput" }

See Also

OpenIDM 4 Release Notes › Major Changes to Existing Functionality (Updated REST API)

Related Training

N/A

Related Issue Tracker IDs

CREST-328 (The REST API should always include _id and _rev regardless of the field filtering)


Copyright and Trademarks Copyright © 2021 ForgeRock, all rights reserved.