- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hello Listers,
How can I parse (splitter and script parser steps) the following REST output to be able to use it in Data Stream Action/IntegrationHub?
{
"data": {
"viewer": {
"account": {
"services": [
{
"serviceId": "svc01",
"serviceName": "svc01 Name"
},
{
"serviceId": "svc02",
"serviceName": "svc02 Name"
}
]
}
}
}
}
I am mainly interested in the "services" section - everything I tried so far is giving me "Internal Server Error" though the REST step executed successfully.
Thanks for any suggestion in the right direction.
Regards,
Victor
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi Bhimashankar H,
Thanks for your response.
In the Script Splitter step, there is no "response" argument. I have tried using "$.data.viewer.account.services" for splitter step and the scriptlet
(function parse(inputs, outputs) {
var item = JSON.parse(inputs.sourceItem);
outputs.targetObject = item;
//tried also outputs.targetObject = item.data.viewer.account.services
})(inputs, outputs);
for script parser step - but I kept on receiving "Internal Server Error"
Thanks,
Victor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi @victor21 ,
To parse the "services" array from this REST output and use it in Data Stream Actions / IntegrationHub, you should use the Script Parser step in your Data Stream definition. The Script Parser extract, transform, and output only the desired part of the response. It will show then ServiceId and Name to map.
(function transform(response) {
return response.data.viewer.account.services;
})(parsedResponse);
This will pass only the list of service objects for mapping.
Using Splitter step:
You set the Splitter JSON Path as data.viewer.account.services if you want each service object to be split as an individual record for the subsequent Action steps.
Thanks,
Bhimashankar H
-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi Bhimashankar H,
Thanks for your response.
In the Script Splitter step, there is no "response" argument. I have tried using "$.data.viewer.account.services" for splitter step and the scriptlet
(function parse(inputs, outputs) {
var item = JSON.parse(inputs.sourceItem);
outputs.targetObject = item;
//tried also outputs.targetObject = item.data.viewer.account.services
})(inputs, outputs);
for script parser step - but I kept on receiving "Internal Server Error"
Thanks,
Victor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi,
Sorry for the confusion - the setting was correct the issue was the output variable that was not set.
Regards,
Victor