Retrieve conditional output based on source input in DataAction

API returns array of objects where objects has userId and source property. The problem is when source equal to "Customer" then I don't have userId property, but if it is "Seller" then I can see userId. Here is my response config:
{
"translationMap": {
"userId": "$[].[].userId",
"source": "$[].[].source"
},
"translationMapDefaults": {
"userId": "null",
"source": "null"
},
"successTemplate": "{"userId": ${userId},"source": ${source}}"
}

Error message:

11. Validate output against schema: JSON failed output schema validation for the following reasons: Schema: # @/properties/userId/items. Error location: /userId/0. instance type (null) does not match any allowed primitive type (allowed: ["string"]), Schema: # @/properties/userId/items. Error location: /userId/1. instance type (null) does not match any allowed primitive type (allowed: ["string"]), Schema: # @/properties/userId/items. Error location: /userId/2. instance type (null) does not match any allowed primitive type (allowed: ["string"]), Schema: # @/properties/userId/items. Error location: /userId/3. instance type (null) does not match any allowed primitive type (allowed: ["string"]), Schema: # @/properties/userId/items. Error location: /userId/4. instance type (null) does not match any allowed primitive type (allowed: ["string"]), Schema: # @/properties/userId/items. Error location: /userId/5. instance type (null) does not match any allowed primitive type (allowed: ["string"]), Schema: # @/properties/userId/items. Error location: /userId/6. instance type (null) does not match any allowed primitive type (allowed: ["string"]), Schema: # @/properties/userId/items. Error location: /userId/7. instance type (null) does not match any allowed primitive type (allowed: ["string"]), Schema: # @/properties/userId/items. Error location: /userId/8. instance type (null) does not match any allowed primitive type (allowed: ["string"]), Schema: # @/properties/userId/items. Error location: /userId/9. instance type (null) does not match any allowed primitive type (allowed: ["string"])

There was similar problem Cycle on array in json response with template - Data Actions - Genesys Cloud Developer Forum. The solution is just changing type of the property that can be null.

Before

"userId": {
      "type": "array",
      "items": {
        "title": "userId",
        "type": "string"
      }
    }

After

"userId": {
      "type": "array",
      "items": {
        "title": "userId",
        "type": [
          "string",
          "null"
        ]
      }
    }

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