- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 08:18 AM
Hi All,
I'm calling REST API via integrationHUB and when I'm parsing the body I'm unable to get proper output. Which should be var results = [{}], so array of objects.
Script
Here are my output variables (can anyone explain what is the Results_child variable that is created automaticaly?)
Everything works fine and I'm getting the data until I try to put it into object. So as soon as I wrap the data in curly bracers inside push method, the result array is empty object.
{
"Results": [
"Zengeon",
0,
0,
"2019-01-18",
"Vitamin Connection",
0,
0,
"2020-02-20",
"WARRIOR SPIRIT",
0,
0,
"2021-01-01",
"Half-Life: Absolute Zero",
0,
0,
"2017-04-17"
]
}
Any help would be appreciated.
Thank you
Tomas
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2023 09:23 AM
@IronPotato Please refer to this page https://docs.servicenow.com/bundle/sandiego-application-development/page/administer/flow-designer/ta...
where starting from point #18 the entire step to create a complex object which is ultimately assigned to an array has been mentioned.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 11:49 AM
@IronPotato Please update the line number 7 as follows.
games.push({'name':game.name,'rating':game.rating,'playtime':game.playtime,'released':game.released});
In a nutshell, the object can be formed by providing key/value pairs.
Hope this help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2023 12:09 AM
Hi @Sandeep Rajput,
as mentioned above, as soon as I want to create proper object it will return results with 1 empty object
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2023 12:39 AM
@IronPotato Could you add a gs.info(JSON.stringify(games)); and check if there is any issue with the way we are creating the object or if the issue lies within the output object.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2023 01:32 AM
