1

I have payload POST call:

{  

   "tenantName":"loki",

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

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

surya
  • 13
  • 4

2 Answers2

0

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

Ori Marko
  • 56,308
  • 23
  • 131
  • 233
0

You can use __groovy() function in order to call RandomStringUtils.randomAlphabetic() method like:

${__groovy(org.apache.commons.lang3.RandomStringUtils.randomAlphabetic(4),)}

replace 4 with the number of your choice to make the random string shorter or longer

enter image description here

The function can be inlined directly into your request body

{
  "tenantName": "${__groovy(org.apache.commons.lang3.RandomStringUtils.randomAlphabetic(4),)}",
  "owner": {
    "country": "india",
    "firstName": "raj",
    "lastName": "kumar",
    "locale": "in",
    "organization": "softwareag",
    "phone": "9789155778",
    "title": "mr",
    "userName": "raraj@softwareag.com",
    "email": "raraj@softwareag.com",
    "password": "V2VsY29tZUAxMjM0"
  },
  "products": [
    "cumulocity",
    "b2b"
  ]
}

More information: Apache Groovy - Why and How You Should Use It

Dmitri T
  • 159,985
  • 5
  • 83
  • 133