cSharp
cSharp

Reputation: 45

JMeter: How to send multiple unique json body?

I have written a REST API and now my requirement is to load test it for 1k calls or something. Problem is the request json has an unique attribute - Cnumber which needs to be changed for every request.

json request:

{ "Code": "WEB", "Pfix": null, "Name": "Ronaldo", "Cnumber": "C7" }

how can I make this request for 1K users concurrently with Cnumber changes in every request?

Upvotes: 0

Views: 955

Answers (2)

w4dd325
w4dd325

Reputation: 617

You could use a timestamp...

{ "Code": "WEB", "Pfix": null, "Name": "Ronaldo", "Cnumber": "C${__time}" }

Cnumber with timestamp example image

Upvotes: 2

Dmitri T
Dmitri T

Reputation: 168147

Depending on what you're trying to achieve:

  1. Incrementing number can be generated using __counter() function like:

    { "Code": "WEB", "Pfix": null, "Name": "Ronaldo", "Cnumber": "${__counter(FALSE,)}" }
    
  2. Random number can be generated using __Random() function

    { "Code": "WEB", "Pfix": null, "Name": "Ronaldo", "Cnumber": "${__Random(1,2147483647,)}" }
    
  3. Random alphanumeric string can be generated using __RandomString() function like:

    { "Code": "WEB", "Pfix": null, "Name": "Ronaldo", "Cnumber": "${__RandomString(2,abcdefjhijklmnopqrstuvwxyz0123456789,)}" }
    
  4. Current thread number: __threadNum() function

    { "Code": "WEB", "Pfix": null, "Name": "Ronaldo", "Cnumber": "${__threadNum}" }
    
  5. GUID-like structure: __UUID() function

    { "Code": "WEB", "Pfix": null, "Name": "Ronaldo", "Cnumber": "${__UUID}" }
    

More information on JMeter Functions concept: Apache JMeter Functions - An Introduction

Upvotes: 3

Related Questions