Could anyone advise how to parse "text/plain" content received from HTTPS response using dp:urlopen() in gateway scripting. We can read the response as "readAsBuffer" to save the context but how can we parse the content. If the response content is application/json we can parse with JSON.parse().
In case of json content -
urlopen.open(options, function(error, response) {
if (error) {
console.log(error);
} else {
if (responseStatusCode == 200) {
hm.response.statusCode = responseStatusCode;
response.readAsBuffer(function(error, Data) {
if (error) {
console.log(error);
} else {
hm.response.statusCode = responseStatusCode;
var response = JSON.parse(Data);
}
});
}
}
});
Please advise me in this regards?