swangl | 2021-12-13 12:14:01 UTC | #1
Hey Forum,
I am having a very similair problem as an older post: Array Search in Data Action, following this example i get an error:
{ "message": "JSON failed schema validation for the following reasons: Schema: # @/properties/priority. Error location: /priority. instance type (array) does not match any allowed primitive type (allowed: [\"integer\"])", "code": "invalid.schema", "status": 400, "messageParams": {}, "contextId": "d1101339-c25f-40d5-99e2-527db74326e6", "details": [ { "errorCode": "ACTION.PROCESSING" } ], "errors": [] }
Where instead of wrapups i try to extract *.conversationRoutingData.priority.
So I hope some of you are able to tell me what it is I do wrong, here is the full JSON format:
Request { "requestUrlTemplate": "/api/v2/conversations/calls/${input.conversationId}", "requestType": "GET", "headers": {}, "requestTemplate": "${input.rawRequest}" }
Response { "translationMap": { "prio": "$.participants[?(@.purpose == 'agent')].conversationRoutingData.priority" }, "translationMapDefaults": {"prio":"-1"}, "successTemplate": "{\"priority\": ${prio}}" }
swangl | 2021-12-14 08:04:46 UTC | #4
For anyone facing the same problem, i did solve it myself.
It turns out that the "key serach" returns an array, which in hindside makes good sense. So in order to get what I wanted, which is a integer, i simply changed the response to the following: Response { "translationMap": { "prio": "$.participants[?(@.purpose == 'agent')].conversationRoutingData.priority" }, "translationMapDefaults": { "prio": "-1" }, "successTemplate": "{\"priority\": ${successTemplateUtils.firstFromArray(${prio})} }" }
Jason_Mathison | 2021-12-14 13:51:49 UTC | #5
Hi swangl,
Congratulations on solving this yourself!
--Jason
This post was migrated from the old Developer Forum.
ref: 12928