Ask a Question

ReadyAPI- Datasink - How to save multiple rows from response into CSV file.

New Contributor

ReadyAPI- Datasink - How to save multiple rows from response into CSV file.

I am trying to map the JSON response attributes with respect to the fields in a test step called Datasink in order to export it in CSV. All i can create is adding columns for the response attributes. i am looking for a help to add the data from repeating attributes in single column by adding rows underneath instead of adding more columns.




"Id" : "123",
      "Name" : abc,
      "ShortName" : abc,

"Id" : "234",
      "Name" : bdc,
      "ShortName" : bdc,


expected CSV from datasink

ID         Name

123       ABC

234       BCD


Community Hero

Hi @sainandam


I'm also using a datasink in almost the same way and so when I read your post - I thought "whats the problem?"


But after having another look at my script and the page (datasink page in - I can see the difference between my script and what yours is doing.


My script is successfully writing new records in my datasink file as rows rather than columns and that's what you are talking about - right? 

I think I know why it's doing this - its because you have multiple records in your json response. 


My script returns a json response with a single record (whereas your response returns multiple records) transfers the attributes to some properties, which are then sourced via the datasink to a flat file, and then I have a dataloop step going back to the rest request which generates my response and repeats - each time writing a new record in a new row in my datasink file.


I had a look in the page I've referenced above just in case there was a certain option like 'append to file' but something more appropriate, but I don't think the OOB functionality on datasinks enables you to do what you want - i.e. write out multiple records in your json response into rows rather than columns in your datasink file.


I've only played around with the datasink functionality a little before now, so I could be mistaken - but I as I say above - I dont think the datasink functionality does what you want - so you have as far I can tell - 2 choices.  Use groovy to handle this (which would probably be quite easy for a scripter - afraid I can't help you there!) or the other choice is to alter your REST request resultset via additional parms to restrict the number of records that are returned in your .json response.


I'm sorry I couldn't be of more help - but at least you now know why the datasink function is working this way!






if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta

Hi @richie,


Thanks for the detailed writeup based on your understanding and experience with the tool.


I think i might need to look out for the solution in groovy as this seems to be a pottential bug in the tool. have seen your comment in the other thread about parametrisation and i know how tedious it will be when we dont know the count.





Showing results for 
Search instead for 
Did you mean: