Search code examples
apitestingpostjmeterpayload

Dynamic values in Rest API using JMeter


I have payload POST call:

{  

   "tenantName":"loki",

 "owner":
 {
    "country": "india",
    "firstName": "raj",
    "lastName": "kumar",
    "locale": "in",
    "organization": "softwareag",
    "phone": "9789155778",
    "title": "mr",
    "userName": "[email protected]",
    "email": "[email protected]",
    "password":"V2VsY29tZUAxMjM0"
 },
  "products": [
    "cumulocity",
    "b2b"
  ]
}

In that payload, the tenant name is unique, How to pass different values for each post call?


Solution

  • You can use __RandomString to randomize name, for example 5 lower case letters:

    ${__RandomString(5,abcdefghijklmnopqrstuvwxyz,)}
    

    RandomString function returns a random String of length using characters in chars to use

    Or load name values from CSV Data set config