Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Error in passing a dynamic array of JSON objects using Data Action

    Posted 17 hours ago
    Edited by Subhajit Podder 6 hours ago

    I want to pass a dynamic array of JSON objects using Data Action. I've created the input with the help of a discussion in community, but I am getting below error. 

    contract.input.inputSchema.properties.responses.type: must be equal to one of the allowed values: [boolean, integer, number, string, null].

    Community URL - Click Here

    Input Sample - 

    {

        "payload": {

            "interaction_id": "23e4ee90-aacc-44b8-9f07-4df887713deb",
            "responses": [
                {
                    "id": 1,
                    "value": "FTSM"
                },
                {
                    "id": 4,
                    "value": "C4D2"
                }
            ]
        }
    }

    Input JSON structure in Data Action - 

    {
      "title": "payload",
      "type": "object",
      "required": [
        "interactionId",
        "responses"
      ],
      "properties": {
        "interactionId": {
          "type": "string"
        },
        "responses": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "id",
              "value"
            ],
            "properties": {
              "id": {
                "type": "integer"
              },
              "value": {
                "type": "string"
              }
            }
          }
        }
      }
    }

    Is it really possible to send the dynamic JSON array or any kind of array as an input of Data Action?  Because, in contract I didn't find any option to pass array as an input.

    If not, then what will be the best way to send the JSON array as Data Action input? Passing the JSON collection as a string and handle in backend?

    What will be my body of the Data Action in this case?


    #Architect
    #DataActions

    ------------------------------
    Subhajit Podder
    NA
    ------------------------------



  • 2.  RE: Error in passing a dynamic array of JSON objects using Data Action

    Posted 4 hours ago

    Hi Subhajit,

    I believe in this case you just create an input contract of type string, let's say "responses" could be the name (as a string type).

    Then on your request body for the data action you just place that input where your whole response array should be.

    So let's take a look at your sample as an example.. You have this:

    {

        "payload": {

            "interaction_id": "23e4ee90-aacc-44b8-9f07-4df887713deb",
            "responses": [
                {
                    "id": 1,
                    "value": "FTSM"
                },
                {
                    "id": 4,
                    "value": "C4D2"
                }
            ]
        }
    }
    Now, on your request body for the Data Action, you should be able to build something like this:

    {

        "payload": {

            "interaction_id": "${input.interactionId}",
            "responses": [
             ${input.responses}
            ]
        }
    }
    It might not look EXACTLY like that, but that should be the idea, have your whole JSON array in a variable on your Architect Flow, and just input everything into the request body of your data action.


    ------------------------------
    Marcello Jabur
    ------------------------------