Genesys Cloud Data Action failing to parse Cognigy JSON response

Trying to fetch profile tokens from NICE Cognigy via a Genesys Cloud Data Action. The GET request returns a 200 with valid JSON, but the action fails with Invalid response format when mapping the output.

  • Endpoint: https://api.nice.com/cognigy/v1/profiles/{id}/tokens
  • Response body: { "accessToken": "abc123", "refreshToken": "xyz789" }
  • Mapping field: accessTokentokenValue

The payload is definitely valid JSON. Any idea why the parser is choking on this?

The Invalid response format error in Genesys Cloud Data Actions is almost always a schema mismatch between what the external API actually returns and what you’ve defined in the Output Schema configuration. Even if the HTTP status is 200, the platform validates the JSON structure strictly. If your schema expects a nested object or a different field type, it throws this generic error.

Since Cognigy returns a flat JSON object like { "accessToken": "abc123" }, you need to ensure your Data Action output schema matches that exactly. A common mistake is defining the output as a complex object when you just need simple key-value pairs, or vice versa.

Here’s how to fix it in Architect:

  1. Go to your Data Action configuration.
  2. In the Output Schema tab, make sure you have defined a field named accessToken with the type string.
  3. Do not wrap it in an extra object unless the response is nested.

If you’re using the Data Action in a flow, you don’t need to do complex parsing. You can reference the output directly:

// In a Set Variable block or similar logic
setVar("tokenValue", dataActionResult.accessToken)

Also, double-check that the Content-Type header in your Data Action request is set to application/json. Sometimes Cognigy sends back text/plain or no content-type, which confuses the parser. Force it by adding a header in the request configuration:

{
 "headers": {
 "Accept": "application/json",
 "Content-Type": "application/json"
 }
}

If the issue persists, try logging the raw response body in the Data Action debug view. You might find hidden whitespace or BOM characters at the start of the JSON that break the parser. Those are invisible but fatal for strict JSON parsers.

One more thing: ensure the OAuth token you’re using for the Cognigy API call has the correct scope. If the token is valid but lacks profile:read, Cognigy might return a 200 with an error message in the body, which isn’t valid JSON for your expected schema. Check the raw body for any { "error": "..." } wrappers.