Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Output Contract unknown number of attributes from API response

    Posted 08-07-2025 14:25

    Hi ,

    I am querying an API which will be providing random number of JSON attributes and so I am having a hard time coming up with the output contract.

    The below is the API JSON return which is currently 16 records however it could be two or five or 8 etc..

    {
      "totalSize": 16,
      "done": true,
      "records": [
        {
          "attributes": {
            "type": "CA",
            "url": "/services/data/v64.0/sobjects/c/a1H0h000004wpZpEAI"
          },
          "Id": "a1H0h000004wpZpEAI",
          "Name": "MCUNK"
        },
        {
          "attributes": {
            "type": "CA",
            "url": "/services/data/v64.0/sobjects/c/a1H0h000004wpa4EAA"
          },
          "Id": "a1H0h000004wpa4EAA",
          "Name": "ORVUNK"
        },
        {
          "attributes": {
            "type": "CA",
            "url": "/services/data/v64.0/sobjects/c/a1H0h000004wpaBEAQ"
          },
          "Id": "a1H0h000004wpaBEAQ",
          "Name": "PFCUNK"
        },
        {
          "attributes": {
            "type": "CA",
            "url": "/services/data/v64.0/sobjects/c/a1H0h000004wpbBEAQ"
          },
          "Id": "a1H0h000004wpbBEAQ",
          "Name": "VLUNK"
        },
        {
          "attributes": {
            "type": "CA",
            "url": "/services/data/v64.0/sobjects/c/a1H0h000004wpamEAA"
          },
          "Id": "a1H0h000004wpamEAA",
          "Name": "RDWUNK"
        },
        {
          "attributes": {
            "type": "CA",
            "url": "/services/data/v64.0/sobjects/c/a1H0h000004wpavEAA"
          },
          "Id": "a1H0h000004wpavEAA",
          "Name": "SBUNK"
        },
        {
          "attributes": {
            "type": "CA",
            "url": "/services/data/v64.0/sobjects/c/a1H0h000004wpawEAA"
          },
          "Id": "a1H0h000004wpawEAA",
          "Name": "SPUNK"
        },
        {
          "attributes": {
            "type": "CA",
            "url": "/services/data/v64.0/sobjects/c/a1H0h000002SkUqEAK"
          },
          "Id": "a1H0h000002SkUqEAK",
          "Name": "JPUNK"
        },
        {
          "attributes": {
            "type": "CA",
            "url": "/services/data/v64.0/sobjects/c/a1H0h000004wpZREAY"
          },
          "Id": "a1H0h000004wpZREAY",
          "Name": "FRONTSSUNK"
        },
        {
          "attributes": {
            "type": "CA",
            "url": "/services/data/v64.0/sobjects/c/a1H0h0000051hfkEAA"
          },
          "Id": "a1H0h0000051hfkEAA",
          "Name": "SBALUNK"
        },
        {
          "attributes": {
            "type": "CA",
            "url": "/services/data/v64.0/sobjects/c/a1H0h000004wpZ0EAI"
          },
          "Id": "a1H0h000004wpZ0EAI",
          "Name": "BERTUNK"
        },
        {
          "attributes": {
            "type": "CA",
            "url": "/services/data/v64.0/sobjects/c/a1Hbc000000jfa5EAA"
          },
          "Id": "a1Hbc000000jfa5EAA",
          "Name": "DPUNK"
        },
        {
          "attributes": {
            "type": "CA",
            "url": "/services/data/v64.0/sobjects/c/a1Hbc000000jfVFEAY"
          },
          "Id": "a1Hbc000000jfVFEAY",
          "Name": "PCUNK"
        },
        {
          "attributes": {
            "type": "CA",
            "url": "/services/data/v64.0/sobjects/c/a1Hbc000000jNjeEAE"
          },
          "Id": "a1Hbc000000jNjeEAE",
          "Name": "WWUNK"
        },
        {
          "attributes": {
            "type": "CA",
            "url": "/services/data/v64.0/sobjects/c/a1Hbc000000jfQPEAY"
          },
          "Id": "a1Hbc000000jfQPEAY",
          "Name": "WDYUNK"
        },
        {
          "attributes": {
            "type": "CA",
            "url": "/services/data/v64.0/sobjects/c/a1H0h000004wpZYEAY"
          },
          "Id": "a1H0h000004wpZYEAY",
          "Name": "HCUNK"
        }
      ]
    }


    I tried something from another thread and seems like it is doing what it is supposed to but if i publish it and use it in architect i get that there are is no output from this data action.

    In the output contract i created an object with two arrays but not sure how to load them with the output contents. In that same thread It showed how to do it with the translation map which works however as stated above if I publish and then go to architect and select it there is no output from this data action.

    Any guidance is truly appreciated.






    #DataActions

    ------------------------------
    Cisco Amaya
    ------------------------------


  • 2.  RE: Output Contract unknown number of attributes from API response

    Posted 08-10-2025 18:34

    This looks similar to a problem I just worked through where I needed to read all rows of a data table where the number of rows is unknown, then loop through the array in Architect.

    The output contract is similar to yours:


    The translation map needs to be setup to accept an array of values, the variable name should start with $..


    I found this article helpful when trying to configure the response template https://help.mypurecloud.com/articles/response-configuration-data-actions/ as well as this JSONPath Readme https://github.com/json-path/JsonPath



    ------------------------------
    Adam Long
    Operations Manager - Voice Systems
    ------------------------------