VaunMcCarthy | 2020-07-09 22:06:57 UTC | #1
DEV---Get-queueID-using-name-20200710100421.custom.json|attachment (1.6 KB)
Could somebody please take a look at the response configuration for the attached? I have changed this from having an array output contract type for the returned Queue ID to being a string, using the firstfromarray option. However I cannot get the overall response configuration correct.
Jerome.Saint-Marc | 2020-07-10 05:33:58 UTC | #2
Hello,
The GET /api/v2/routing/queues does not have a "results" attribute in the returned structure (in the response to this GET). If the request finds queue(s) they will be returned in "entities" (which is an array). If you want to get the id of the first queue returned in the "entities" array, and if you want to return "0" if no Queue was found/returned via this request, I think the following should work in the Response Configuration:
{ "translationMap": { "queueid": "$.entities[0].id" }, "translationMapDefaults": { "queueid": "\"0\"" }, "successTemplate": "{\"QueueID\": ${queue_id} }" }
As a note, there is a "Find Queue" action/block that you can invoke from the Architect flows.
Regards,
VaunMcCarthy | 2020-07-11 21:23:30 UTC | #3
Thanks Jerome
I spotted that results attribute mistake later too.
When would you use this [0] approach to get the first in the array rather than using the firstfromarray option in the successtemplate?
Jerome.Saint-Marc | 2020-07-12 08:44:43 UTC | #4
Both can work. You can use JSONPath in the translation map (ex: json path using a reference/index) to get a specific entry in the array. There are differences - ex: how firstFromArray manages default values (default value for an empty array).
In this specific example, if I am not mistaken, the thing is that the request will not return "entities" attribute if there are no found queues (it doesn't return an "entities" empty array attribute - the "entities" attribute is just not present in the response). So if there are no queues returned, access to \$.entities[0] will fail. And in such case, it will use the default value defined in translationMapDefaults.
Regards,
system | 2020-08-12 08:44:46 UTC | #5
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: 8248