Saving response data in the simulation


I do have scenario where i would like to save the response data which i get after my simulation executes.Usually before cases i took data from my database,but here i would like to save it within the simulation as a CSV file.

{“GetProrateWithTaxResponseMessage”:{“responseCode”:“1”,“addedItems”:{“orderQuotationInfo”:[{“costBreakdown”:{“bill”:{“from”:“22-11-2018”,“priceToBeCharged”:60.00,“priceAfterTax”:67.780000,“taxRate”:0.129600,“tax”:7.78}},“serviceId”:“FOXNATION12M-WEB”,“serviceType”:“PACKAGE”,“serviceName”:“FX Nation Yearly Subscription”,“displayOrder”:“4”,“displayName”:“Yearly”,“originalPrice”:64.99}]},“totalTax”:7.78,“totalPriceAfterTax”:67.78,“totalDiscountAmount”:0,“totalTaxRate”:0.129600,“nextBillingDateTime”:1543579200000}}

Here i would like to save the following parameters which i get in the api response as a CSV file.



can anyone help me on this??

seems easy, if i understand the question… You first get the body from your response, parse your json, grab those fields, create a file stream and dump it.
but maybe you are asking how to extract the response body…?
If that is so, i usually first use saveAs in a check and then retrieve it from the session in a subsequent exec. See:

Hi Max…

My question is can we save the data which we get in response body directly into my local system as a file.Previously i used to ask my DBops for the response data whatever i get after my test completion.

Let me know if i am wrong…

Ganesh Kakani

Hi Ganesh,

I’m using the following code snippet (which uses one helper library)

val home: ChainBuilder = exec(http("Home") .get("/") .check( bodyBytes.saveAs("lastResponse"))) .exec(session => { JsonResponseTool.saveToFile(session, "lastResponse", "githubapi", "home") session })