Legacy Dev Forum Posts

 View Only

Sign Up

Need Assistance with Data Action

  • 1.  Need Assistance with Data Action

    Posted 06-05-2025 18:46

    Scott_Stewart | 2024-10-30 21:12:48 UTC | #1

    I am trying to create a data action to get the supervisor name using Genesys API /api/v2/users/{userId}/superiors. But when I run the data action, I am getting an error stating: 13. Flatten: Too many results matched criteria. If I uncheck the box to flatten output", the data action works fine and I get the intended result.

    I tried to resolve the issue by updating the translation map as follows:

    { "translationMap": {"name": "$.['name']"}, "translationMapDefaults": {}, "successTemplate": "{\n \"name\": ${successTemplateUtils.firstFromArray(\"$.['name']\",\"${esc.quote}UNKNOWN${esc.quote}\")}\n}" }

    I then received an error stating: 9. Resolve translation map: Failed while processing the translation map. Could not resolve value for the key: 'name' and no default value was configured. Additional details: Expected to find an object with property ['name'] in path $ but found 'java.util.ArrayList'. This is not a json object according to the JsonProvider: 'com.jayway.jsonpath.spi.json.JsonSmartJsonProvider'.

    Appreciate any help you can provide with this.

    Here is the JSON request:

    { "name": "Get Agent Supervisor (Copy) - Exported 2024-10-30 @ 7:48", "integrationType": "purecloud-data-actions", "actionType": "custom", "config": { "request": { "requestUrlTemplate": "/api/v2/users/${input.userId}/superiors", "requestType": "GET", "headers": { "content-type": "application/json" }, "requestTemplate": "${input.rawRequest}" }, "response": { "translationMap": {}, "translationMapDefaults": {}, "successTemplate": "${rawResult}" } }, "contract": { "input": { "inputSchema": { "title": "userId", "type": "object", "properties": { "userId": { "type": "string" } }, "additionalProperties": false } }, "output": { "successSchema": { "title": "name", "type": "array", "items": { "title": "Item 1", "type": "object", "properties": { "name": { "type": "string" } }, "additionalProperties": true } } } }, "secure": false }

    Here is the output: [ { "id": "650902af-7e78-47db-b165-14ab2eb97004", "name": "xxxxx xxxxxx", "chat": { "jabberId": "xxxxxxxxxxxxx@xxxxx.xxxxxx.com" }, "department": "Service Operations", "email": "xxxxxxxx@xxxxxxx.com", "primaryContactInfo": [ { "address": "xxxxxxx.xxxxxx@xxxxxxx.com", "mediaType": "EMAIL", "type": "PRIMARY" }, { "address": "+1xxxxxxxxxx", "display": "+1 xxx-xxx-xxxx", "mediaType": "PHONE", "type": "PRIMARY" } ], "addresses": [ { "address": "xxxxx.xxxxx@xxxxxxx.com", "mediaType": "EMAIL", "type": "WORK" }, { "address": "+1xxxxxxxxxx", "display": "+1 xxx-xxx-xxxx", "mediaType": "PHONE", "type": "WORK", "countryCode": "US" }, { "address": "+1xxxxxxxxx", "display": "+1 xxx-xxx-xxxx", "mediaType": "PHONE", "type": "WORK2", "countryCode": "US" }, { "address": "+1xxxxxxxxxx", "display": "+1 xxx-xxx-xxxx", "mediaType": "PHONE", "type": "WORK3", "countryCode": "US" } ], "state": "active", "title": "xxxxxxxxxxxx", "username": "xxxxxxxxx@xxxxxxx.com", "manager": { "id": "15216105-d9dd-4e66-9b58-6d74f1b129eb", "selfUri": "/api/v2/users/15216105-d9dd-4e66-9b58-6d74f1b129eb" }, "version": 27, "acdAutoAnswer": false, "selfUri": "/api/v2/users/650902af-7e78-47db-b165-14ab2eb97004" }, { "id": "15216105-d9dd-4e66-9b58-6d74f1b129eb", "name": "xxxxxxx xxxxxxxxx", "chat": { "jabberId": "xxxxxxxxxxxxxx@xxxxxxxx.orgspan.com" }, "department": "Service Operations", "email": "xxxxxxx@xxxxxx.com", "primaryContactInfo": [ { "address": "xxxxxxx.xxxxxxx@xxxxxxx.com", "mediaType": "EMAIL", "type": "PRIMARY" }, { "address": "+1xxxxxxxxxx", "mediaType": "SMS", "type": "PRIMARY" }, { "address": "+1xxxxxxxxxx", "display": "+1 xxx-xxx-xxxx", "mediaType": "PHONE", "type": "PRIMARY" } ], "addresses": [ { "address": "xxxxxxx.xxxxxxx@xxxxxxx.com", "mediaType": "EMAIL", "type": "WORK" }, { "address": "+xxxxxxxxxx", "display": "+1 xxx-xxx-xxxx", "mediaType": "SMS", "type": "MOBILE", "countryCode": "US" }, { "address": "+1xxxxxxxxxx", "display": "+1 xxx-xxx-xxxx", "mediaType": "PHONE", "type": "WORK", "countryCode": "US" }, { "address": "+1xxxxxxxxxx", "display": "+1 xxx-xxx-xxxx", "mediaType": "PHONE", "type": "WORK2", "countryCode": "US" }, { "address": "+1xxxxxxxxxx", "display": "+1 xxx-xxx-xxxx", "mediaType": "PHONE", "type": "WORK3", "countryCode": "US" } ], "state": "active", "title": "xxxxxxxx xxxxxxxx", "username": "xxxxxxx@xxxxxxx.com", "manager": { "id": "ec63e2cf-0b6a-4c59-8adf-f67fe423ed58", "selfUri": "/api/v2/users/ec63e2cf-0b6a-4c59-8adf-f67fe423ed58" }, "images": [ { "resolution": "x48", "imageUri": "https://api-downloads.usw2.pure.cloud/directory-profile/49431f39/0625/46da/8fd1/a9f7dbb70d20.jpg" }, { "resolution": "x96", "imageUri": "https://api-downloads.usw2.pure.cloud/directory-profile/d1482ce4/cf6e/439a/9371/26f37dc5cc59.jpg" }, { "resolution": "x128", "imageUri": "https://api-downloads.usw2.pure.cloud/directory-profile/5812f5d9/dd6c/45fa/a826/b5f0614c8883.jpg" }, { "resolution": "x200", "imageUri": "https://api-downloads.usw2.pure.cloud/directory-profile/fbd7d7d2/c463/4043/ac81/0bd52fb56369.jpg" }, { "resolution": "x300", "imageUri": "https://api-downloads.usw2.pure.cloud/directory-profile/30900c29/3a64/4a09/9c32/7b65e8852144.jpg" }, { "resolution": "x400", "imageUri": "https://api-downloads.usw2.pure.cloud/directory-profile/ffdff691/12c3/4241/8511/fc67a1037091.jpg" } ], "version": 23, "acdAutoAnswer": true, "selfUri": "/api/v2/users/15216105-d9dd-4e66-9b58-6d74f1b129eb" }, { "id": "ec63e2cf-0b6a-4c59-8adf-f67fe423ed58", "name": "xxxxxxx xxxxxxx", "chat": { "jabberId": "xxxxxxxxxxxxxx@xxxxdxxx.orgspan.com" }, "department": "Service Delivery", "email": "**@***.com", "primaryContactInfo": [ { "address": "*.*@***.com", "mediaType": "EMAIL", "type": "PRIMARY" }, { "address": "+1***", "display": "+1 **-*-**", "mediaType": "PHONE", "type": "PRIMARY" } ], "addresses": [ { "address": "**.**@***.com", "mediaType": "EMAIL", "type": "WORK" }, { "address": "+1*****", "display": "+1 *-*-**", "mediaType": "PHONE", "type": "WORK", "countryCode": "US" } ], "state": "active", "title": "*, Service Operations", "username": "***@***.com", "version": 20, "acdAutoAnswer": true, "selfUri": "/api/v2/users/ec63e2cf-0b6a-4c59-8adf-f67fe423ed58" } ]


    Scott_Stewart | 2024-10-30 23:10:06 UTC | #2

    I was able to get the data action working "sort of" :grinning: I am now getting back an array of data in the repsonse and need assistance with getting the supervisor name to show in the result window. Here is my current Translation map:

    {
      "translationMap": {
        "name": "$.[0]name"
      },
      "translationMapDefaults": {},
      "successTemplate": "{\n   \"name\": ${name}\n}"
    }


    Scott_Stewart | 2024-10-31 12:45:21 UTC | #3

    After much trial and error I was able to resolve the issue. I updated my output contract to the following:

    {
      "title": "name",
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        }
      },
      "additionalProperties": true
    }

    And I updated the Translation Map to the following:

    {
      "translationMap": {
        "name": "$.[0]name"
      },
      "translationMapDefaults": {},
      "successTemplate": "{\"name\": ${name}\n}"
    }

    Now everything is working properly.


    system | 2024-12-01 12:45:24 UTC | #4

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 30124