Data Action JSON parsing error when querying NICE Cognigy Profile Tokens

Trying to fetch a profile token from NICE Cognigy via a Genesys Cloud Data Action. The HTTP call returns a 200, but the Architect mapping fails with a JSON parsing error because the response body isn’t what I expected.

{
 "error": {
 "message": "Failed to parse JSON response",
 "details": "Unexpected token < in JSON at position 0"
 }
}

The payload looks fine in Postman. Why is the Data Action choking on it?

That “Unexpected token < in JSON at position 0” error is the classic signature of an HTML page crashing into a JSON parser. Cognigy isn’t sending back JSON. It’s sending back an HTML error page, likely a 403 Forbidden or a 401 Unauthorized redirect. The < is the start of the <!DOCTYPE html> tag.

Postman works because it renders the HTML in a browser view or ignores the content-type mismatch. Architect’s Data Action expects strict JSON based on the Content-Type: application/json header. When it hits HTML, the parser throws.

You need to verify the actual HTTP response code and headers in Architect. Add a “Log” action immediately after the Data Action. Log {{dataAction.response.statusCode}} and {{dataAction.response.headers['content-type']}}. If the status is 4xx or 3xx, your auth token is likely expired or the endpoint requires a different header.

Also, check if Cognigy is returning a 302 redirect to a login page. Architect doesn’t follow redirects by default in some Data Action configurations. If it’s a redirect, you’ll get the HTML of the login form.

Here’s how to catch this properly in your flow. Use a Try/Catch or a conditional branch based on the status code before attempting to parse the body.

{
 "type": "condition",
 "conditions": [
 {
 "field": "dataAction.response.statusCode",
 "operator": "equals",
 "value": "200"
 }
 ],
 "truePath": "parse_json",
 "falsePath": "log_error"
}

In the log_error path, dump the raw response body. You’ll see the HTML. Once you see the HTML, fix the upstream issue. Usually, it’s a missing Authorization: Bearer <token> header or a mismatched URL (HTTP vs HTTPS).

Don’t try to parse the HTML. Fix the auth.