JSON Response body is an array, parse using script step not working

Chad R
Tera Expert

Hello All!

 

I have beat my head against the wall for awhile, first I will say I know the JSON Parser step will do what I'm about to ask about but I am trying to see if I can do this without it for obvious reasons :). 

 

First I have a JSON response body form a third party that I go and get and I am attempting to parse that into an object and feed it into an output to use in designer flows. First here is the very large and ugly response body:

 

{
"ReceiveMessageResponse": {
"ResponseMetadata": {
"RequestId": "1808480e-ebc9-5f83-bbe1-15f4b3fbb859"
},
"ReceiveMessageResult": {
"messages": [
{
"MessageId": "7b1a126b-e895-4d93-a559-de50291e45a4",
"ReceiptHandle": "AQEBF8HfWTWyRVMKeGe2HGWVJZ8wq9QKTa7hbVrX+8pqK/TP1SUHln9h/lUPdQ2RSuO8qVog0+uANGY2UMHbmV1P4DL0EkhcaBcKuZqhiyOxJVFiGR9pxZNURRDlO2u6iyZW3s9ja2bozk4oIEtD8xQFmviqdXGlvAbYer3P2914h0/PgHC8xWm8txynlw3BqWB2zfBFsH4S19e6jLgsNdGtBLZe0NHCfSfgIU0mkwkZW5Jko2mNOZMhIYIKw7oIKlkeaTP4F9PNmBzuyAZBhMc2bowtP2ZJ3+luBW9AYx7cr2A=",
"MD5OfBody": "f2049eb6afe382aeff2509c02905b3db",
"Body": {
"clientName": "Conduent Business Services Global",
"ticketNumber": "e-CS001333807",
"clientTicketNumber": "",
"ticketType": "Incident",
"status": "open",
"description": "test\r\n\r\nHELLO WORLD",
"shortDescription": "test",
"group": "Ensono MF CICS",
"ensonoGroup": "MF - GTS CICS",
"priority": "4",
"impact": "4",
"urgency": "4",
"openedTime": "2023-12-14T18:20:42Z",
"category": "Azure",
"origin": "Internal Request",
"cis": ""
},
"Attributes": {
"SenderId": "AROAYCQITFFPIEBOQI2KM:envxsn2qdev1SN2QBridge",
"ApproximateFirstReceiveTimestamp": "1702578111786",
"ApproximateReceiveCount": "34",
"SentTimestamp": "1702578096232",
"SequenceNumber": "37329348140054496000",
"MessageDeduplicationId": "38770e8d565e24fa4dd2db1ddd85d4c713728bebf6eafec76f7c91574874d7f5",
"MessageGroupId": "e-CS001333807",
"AWSTraceHeader": "Root=1-657b47af-4c0f31211b35a2b1051f0cf3;Parent=141b9e3d75ea8d4a;Sampled=0;Lineage=eac5e8ee:0",
"ClientReferenceAvailable": false,
"TransactionType": "Create"
}
},
{
"MessageId": "e27eb7fc-b09e-49b8-8e78-127941cc1310",
"ReceiptHandle": "AQEBUXyz9uVJFvCwdqhrWw38G7qJkIHh+GILFohX524p350nGOXtaDTAfXI2RuDStoNt0A0IscyGcO6tcd/AqbIbfoMz0Pdnww2F4yO8ipDjV73h9p1VH85SGrk/Ln2MCr8opVXEThMsl78O0tqNjvpQh8RJrqWyXPopaYSTIIrWTGTxRlUtQ5CnFvmqG1FWA+OnfIfa1HYfFi//IyNJZbG5bFXgTNznAWvVtvtMnfId0cMqPsttl9D/O4hmRGMuJc8NhAXgye9rOB/zI4J9wpXSc4pHl/Re01Pe9kBvZqB7hws=",
"MD5OfBody": "1173c47afc2501d26e6104909b958a3d",
"Body": {
"clientName": "Conduent Business Services Global",
"ticketNumber": "e-CS001333807",
"clientTicketNumber": "",
"ticketType": "Incident",
"status": "open",
"description": "test\r\n\r\nHELLO WORLD",
"shortDescription": "testing update",
"group": "Ensono MF CICS",
"ensonoGroup": "MF - GTS CICS",
"priority": "4",
"impact": "4",
"urgency": "4",
"openedTime": "2023-12-14T18:20:42Z",
"category": "Azure",
"origin": "Internal Request",
"cis": "",
"changed": {
"updatedOn": "2023-12-14T18:22:31Z",
"shortDescription": "testing update"
},
"updatedOn": "2023-12-14T18:22:31Z"
},
"Attributes": {
"SenderId": "AROAYCQITFFPIEBOQI2KM:envxsn2qdev1SN2QBridge",
"ApproximateFirstReceiveTimestamp": "1702578247021",
"ApproximateReceiveCount": "33",
"SentTimestamp": "1702578175547",
"SequenceNumber": "37329348160359135488",
"MessageDeduplicationId": "30322e496c8bd8d48d00331024899110db44a3db2ce717cdfd7dd8a4f0811acb",
"MessageGroupId": "e-CS001333807",
"AWSTraceHeader": "Root=1-657b47ff-17bb1ca77e0e9eed3cd9274d;Parent=5c6578462a250865;Sampled=0;Lineage=eac5e8ee:0",
"ClientReferenceAvailable": false,
"TransactionType": "Update"
}
},
{
"MessageId": "786c1a13-75e7-4ff1-930c-8d335f082a15",
"ReceiptHandle": "AQEBH2SQ87p2n1gBOFTyUTkiVoKjizFeZaN5XF1zVBK0vhG/XJDFlD60x0E2r+XH8XMvF5RhEDhn8eAx9NGskw3j7o5vdbreMDCWPYDWSwZGBRKKcLUYnETtD7P0MV9jUzzibUEkgH8sfz4YJH9ku9awtpVSskqsMhOx+uKNr51cjwX4z7n1r+oA08+L1A/Evgovjednr5cFzZvBP76/zIvuh7ze5/zod3KXVS5Lqo5Moximi4hbjHSAxIpn3LI3e2uZkYyi3NjXWhXFFc9ukVLQnXYS0h/jwAPsWc0C2w4b/Kw=",
"MD5OfBody": "44211efc64d16d23ba6c6779d0e04623",
"Body": {
"clientName": "Conduent Business Services Global",
"clientTicketNumber": "",
"ticketType": "Incident",
"ticketNumber": "e-CS001333807",
"updatedOn": "2023-12-14T18:22:01Z",
"notes": {
"type": "comment",
"id": "d43caaa61b0bf91426a2da49b04bcb28",
"body": "hello world comment!",
"commenter": "Joshua Jenkins",
"commenterEmail": "Joshua.Jenkins@Ensono.com"
}
},
"Attributes": {
"SenderId": "AROAYCQITFFPIEBOQI2KM:envxsn2qdev1SN2QBridge",
"ApproximateFirstReceiveTimestamp": "1702578247021",
"ApproximateReceiveCount": "33",
"SentTimestamp": "1702578176428",
"SequenceNumber": "37329348160584671488",
"MessageDeduplicationId": "385a94e0523b87b821da8a30559c6dc1ec3470f7a7acd6795d4cf0ea1ed5c613",
"MessageGroupId": "e-CS001333807",
"AWSTraceHeader": "Root=1-657b4800-5466b83324e60c4164344bcb;Parent=31936b855640dc40;Sampled=0;Lineage=eac5e8ee:0",
"ClientReferenceAvailable": false,
"TransactionType": "Notes"
}
},
{
"MessageId": "58509a36-c7fc-47c4-ac58-39a7aa1cafc9",
"ReceiptHandle": "AQEBTS9kBGdvmwEV6NAb+VJVXJPH44X3KqlpFczwCNcjVXCDt8NM+usOnSVp1BiMSkunvB3NTxqQHjpj7FYsBV1E4GKK6jXig/6Ud5ZpaODuBqmtFl2UiLrGzGYcf1v+Tpb6EDsIK/EHPUXJnbI+v7a84FYcKnyuOhT+6yWjkKAcuoUtxQ1TAy5ms/b6Xf67NofnFqkNazYm1+LLL9uzOtrquXDr5J4I9CkBxTQsM1TYIDtJoVKuORuH3LANRRzmhqPvBjCrrJ6kfK/1v/7yNv+Us9Bp048NHBDsYiZYxM0YV78=",
"MD5OfBody": "6e76cadaa034ee800b7a171f780531c4",
"Body": {
"clientName": "Conduent Business Services Global",
"clientTicketNumber": "",
"ticketType": "Incident",
"ticketNumber": "e-CS001333807",
"attachmentName": "banff.jpg",
"attachmentSize": "509121",
"attachmentType": "image/jpeg",
},
"Attributes": {
"SenderId": "AROAYCQITFFPIEBOQI2KM:envxsn2qdev1SN2QBridge",
"ApproximateFirstReceiveTimestamp": "1702578247021",
"ApproximateReceiveCount": "33",
"SentTimestamp": "1702578195538",
"SequenceNumber": "37329348165476831232",
"MessageDeduplicationId": "c5f2047b3d5f380dabba67b4bdcf8497af00b416c6a9e7fc78a24176c9537b1e",
"MessageGroupId": "e-CS001333807",
"AWSTraceHeader": "Root=1-657b4812-0c24afbe4bbb63c908aed0d3;Parent=429d54b90ef2fde2;Sampled=0;Lineage=eac5e8ee:0",
"ClientReferenceAvailable": false,
"TransactionType": "Attachment"
}
}
]
}
}
}
 
With that out of the way here is my script step that takes the response body and attempts to place it into a usable output and each time this returns blank:
 
Screenshot 2023-12-18 at 11.02.44 AM.png
 
Here is the output variables structure I built out and I am trying to map the output to root as seen in the script above, any help here is greatly appreciated. 
Screenshot 2023-12-18 at 11.03.37 AM.png
 
6 REPLIES 6

Aman10
Tera Contributor

Hello @Chad R 
can you try 

var body = input.response_body;
var resultsObj = JSON.parse(body);
outputs.root = resultObj;

 

Hi Aman,

 

Thanks for the reply, I have tried that and also just tried again and the output just shows blank when I test. I'm convinced that service now has made it so if I want to do this in flow designer I am going to need to get the parser step. I appreciate everyones responses I have been working on this in the background and still have been unable to get the result im looking for without it.