Help with Data Driven Tests

Hi Postman community can anyone help me with one issue, we want to post only one value with the help of csv file and other keys and values for same request we have used variables, we just have to POST one key value with the help of external CSV file

Please find below attachments, and guide us through just how to put “value” with help of csv file.

and also if we get sample format for same csv file that will be really gratful

The CSV file needs a single column with a header.

You reference the data by the header name.

So if you call the header “value”, then you would just reference it in the body using {{value}}, same as any other variable.

This is covered in the following Postman Blog.

So do we have to declaire local variable as “value” in POSTMAN envirounment?

You don’t have to declare value, as its coming from the CSV file, not an environment variable.

It still uses the curly brackets in the body.

@michaelderekjones also do I have to remove key “value from the request body” as we are passing as header trough CSV

No, the key name needs to stay in the body.

It’s just the value that you are parameterising from the CSV file.

It should be

"value": {{value}}

@michaelderekjones and what changes needs to be done in TEST and pre-request script tabs

You don’t need to put anything in the pre-request script or the tests tab.

You just need to update the body of the request and parameterise the value.

The same concept as you’ve got for timestamp. The only difference is that its pulling it from the CSV file.

Have you tried going through the example that is provided in the link.

It should help understand the concept.

@michaelderekjones I have followed the steps from above link which you have provided, but getting 500 Internal Server error. PFB


csv

If you have three values, you need to separate them into three columns.

Your initial post said you want to post one key value.

It looks like you need three different values. So same as you’ve done for the timestamp.

Follow the same naming convention, so value0, value1 and value2.

Then change the variables in the body to match {{value0}}, {{value1}}, etc.

Tried with below thing still getting 500 error

csss

@michaelderekjones can you please send sample request body and csv for above example that will be really helpfull.

Your CSV file needs to have the data in three separate columns, not a single column.

Your variables in your body need to match those column headers.

image

@michaelderekjones It work this Time ! :+1:t2:
Thanks alot @michaelderekjones for help. :+1:t2:

1 Like

Hi @michaelderekjones can you please guide me, can I insert uuid in in request URL though same CSV file which I have use for values, as I have to POST data for multiple ID’s

I really think you need to re-read the CSV import instructions and follow the small tutorial they have.

It shows how to parameterize parts of the URL.

But yes, just create a header in the CSV file called UUID, and replace that part of the URL with {{UUID}}

Same process as we’ve used to target the other elements.

I would also suggest that you go through the Postman Learning Centre first which can be accessed on the Postman home page.

Those courses explain the basic concepts that I recommend you learn first. Including how to use variables.

image

Skip down to Postman Training on the next page.

From here, I recommend the Galaxy APIs 101, and Galaxy Testing and Automation as this covered all of the basics for me. This will include storing environment variables.

image

For more info on variables.

Using variables | Postman Learning Center

@michaelderekjones Thank for the help :+1:t2:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.