0
votes

I have a csv file that looks like this:

varCust_id,varCust_name,varCity,varStateProv,varCountry,varUserId,varUsername

When I run the HTTP Post Request to create a new customer, I get a JSON response. I am extracting the cust_id and cust_name using the json extractor. How can I enter this new value into the csv for the correct variable? For example, after creating the customer, the csv would look like this:

varCust_id,varCust_name,varCity,varStateProv,varCountry,varUserId,varUsername
1234,My Customer Name

Or once I create a user, the file might look like this:

varCust_id,varCust_name,varCity,varStateProv,varCountry,varUserId,varUsername
1234,My Customer Name,,,,9876,myusername

In my searching through the net, I have found ways and I'm able to append these extracted variables to a new line but in my case, I need to replace the value in the correct location so it is associated to the correct variable I have set up in the csv file.

3

3 Answers

0
votes

I believe what you're looking to do can be done via a BeanShell PostProcessor and is answered here.

0
votes

Thank you for the reply. I ended up using User Defined Variables for some things and BeanShell PreProcessors for other bits vs. using the CSV.

0
votes

Well, never tried this. But what you can do is create all these variables and set them to Null / 0.

Once done, update these during your execution. At the end, you can concatenate these with any delimiter (say ; or Tab) and just push in CSV as a single string. Once you got data in CSV, you can easily split in Ms excel.