Momoka_Tachibana | 2022-02-18 14:24:41 UTC | #1
I am struggling to extracts multiple elements from the array at SuccessTemplate. I was going to use output contracts without using Translation map but I was having trouble getting the results of the elements from nested array. When I looking at some documents : https://developer.genesys.cloud/forum/t/api-is-returning-data-but-architect-errors-out-when-trying-to-print-the-data/12521 I found out Flattening does not support nested arrays, so I guess that is the reason for why I could not get them.
So now, I am trying to find another way to extract them by using Success Templates and Translation Map. But I am now stuck on the Success Template Section because I am not sure how I can get multiple elements from the array.
Could you please help me with this?
{ "result": { "resultHeader": { "USTime": "2022-02-20T16:00:00.12344" }, "resultBody": { "USTimeList": [ { "USDateCd": "20220220", "timeList": [ { "USTimeId": "0000" }, { "USTimeId": "1111" }, { "USTimeId": "2222" }, { "USTimeId": "3333" }, { "USTimeId": "4444" } ] }, { "USDateCd": "20220221", "timeList": [ { "USTimeId": "0000" }, { "USTimeId": "1111" }, { "USTimeId": "2222" }, { "USTimeId": "3333" }, { "USTimeId": "4444" }, { "USTimeId": "5555" } ] } ] } } }
Jason_Mathison | 2022-02-18 14:41:59 UTC | #2
Hi Momoka,
Depending on how your API works, one option might be to use a JSONPath like result.resultBody.USTimeList[0] to get the first result and result.resultBody.USTimeList[1] to get the second etc. You can use a tool like http://jsonpath.herokuapp.com/ to see what that would resolve to.
If your API always returns the first day first and the second day second you might be able to get that to work for you.
Otherwise you may need to fall back to a lambda data action where a little bit of python or javascript can convert the response into something that data actions / architect can easily handle.
--Jason
system | 2022-03-21 14:42:52 UTC | #3
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: 13637