2
votes

I am testing a REST API that creates a user. This API uses POST method and requires a json payload. I am using the HTTP Request Sampler for my requests which accepts a file for the request payload. The issue I'm having is that the request returns a 409 Conflict for all the hits except for the first thread because after the first thread is executed, the user already exists. Is there a way I can tell JMeter to pick a different payload before each request? How can I organize my request payload for this purpose?

2

2 Answers

0
votes

In your payload file you can concatenate your username with jMeter function that makes it unique:

"username": "user ${__time()}"

instead of time function you can either use __UUID or even a __counter function. You can also combine the functions together. Have a look here:

https://www.blazemeter.com/blog/apache-jmeter-functions-introduction

-1
votes

You will have to parametrized your test plan and use CSV data set config to use the data from csv file. I have created a beginners screen cast to explain how to use csv data set config .

As you mentioned you cannot reuse the same data, you will have to either create a big enough csv to match or your concurrent user needs, or use once only controller to not replay those request again, which will create duplicate users.