Flow Designer Parse JSON Response using new lines on Work Notes

Ivan39
Tera Contributor

I'm trying to parse the JSON Response from the API call with new lines and then update the work notes. It seems like during the test, the response is not being parsed as expected.

 

Anyone knows how to parse this correctly so the work notes can be updated correctly using the new lines?

 

JSON Response sample:

{"generated":"2023-12-15T21:03:05.550Z","reports":[{"scope":"THREAT","id":"48f4f8a0b2147eaf7f340c5820fe0e97de07aaefe7e57a915b216d20523da495","name":"48f4f8a0b2147eaf7f340c5820fe0e97de07aaefe7e57a915b216d20523da495","threatStatus":"active","forensics":[{"type":"attachment","display":"Image Based TOAD Threat with SHA-256: 48f4f8a0b2147eaf7f340c5820fe0e97de07aaefe7e57a915b216d20523da495","engine":"iee","malicious":true,"note":"Attachment with SHA-256: 48f4f8a0b2147eaf7f340c5820fe0e97de07aaefe7e57a915b216d20523da495","time":0,"what":{"rule":"14ab0a31-307e-11ed-afa2-1866da63294b","sha256":"48f4f8a0b2147eaf7f340c5820fe0e97de07aaefe7e57a915b216d20523da495","blacklisted":true},"platforms":[{"name":"analyst","os":"analyst","version":"0"}]}]}]}

 

Sample code:

(function execute(inputs, outputs) {
var response_body = JSON.parse(inputs.ResponseBody);
var reports = response_body.reports[0].toString();
var sentences = reports.split(',');
var format = sentences.join (',\n');
outputs.responsebody = format;
})(inputs, outputs);
5 REPLIES 5

I think if your output type  in flow is JSON, then you don't need to use "JSON.parse"

Try in that way.

 

Thanks,

Narsing