saveResponseBodyAsAttachment works but stops next script code.

jacc_99
Giga Guru

Hi,

I get a response file through RestMessage call. Next I copy this response in CSV file as attachment in a data source record already created. Then I need check the response in log and execute the data source and transform map with script.

var req = new sn_ws.RESTMessageV2('rest_name', 'method_name');
req.saveResponseBodyAsAttachment('target_table', 'sys_id_record', 'file_name.csv');
var response = req.execute();
response.waitForResponse(500);
gs.info('&&&Test response \n' + response.getBody());

// Trigger data source and transform map with script

The problem is if I copy the csv file through saveResponseBodyAsAttachment the next part of my code doesn't execute.

If I comment the line req.saveResponseBodyAsAttachment('target_table', 'sys_id_record', 'file_name.csv') and attach the .csv file to the data source manually, when I execute the code, I can see in log the response, response.getBody(), and the part of code that I named in the code above like "Trigger data source and transform map with script" works perfectly.

Why the method saveResponseBodyAsAttachment stop everthing after it in my code?

There is some way to solve this or another solution with script code? 

 

Thanks in advance

1 ACCEPTED SOLUTION

jacc_99
Giga Guru

I found the problem.

In gs.info('&&&Test response \n' + response.getBody()); getBody() is not supported.

That was the error!

View solution in original post

5 REPLIES 5

jacc_99
Giga Guru

I found the problem.

In gs.info('&&&Test response \n' + response.getBody()); getBody() is not supported.

That was the error!