# How to add random string in Json???

**URL:** https://community.gatling.io/t/how-to-add-random-string-in-json/1749
**Category:** Gatling (Open-Source)
**Created:** [November 27, 2014, 11:17am UTC](https://community.gatling.io/t/how-to-add-random-string-in-json/1749 "2014-11-27T11:17:39Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![47saikumar](https://avatars.discourse-cdn.com/v4/letter/4/a9a28c/32.png) [@47saikumar](https://community.gatling.io/u/47saikumar)
#### Post date: [November 27, 2014, 11:17am UTC](https://community.gatling.io/t/how-to-add-random-string-in-json/1749/1 "2014-11-27T11:17:39Z")

</div>

Hi,

I am new to gatling and I want to add the Random string to json every time…Because my api will not support the same title of post every time…So for that I have to add  
some random string every time…How to add???please help me…Here I am giving the brief info of my code

val TestRequest: String = new JSONObject(Map(“title” → “Gatling Stress Test”,“description” → “Gatling is a highly capable stress testing tool.”)).toString()

.body(new StringBody(TestRequest))

So for title I have to add random string for each user every time…How to do that???Please suggest other than the values from session…

Thanks

---

<div class="post-metadata">

### Author: ![Abhinav\_Gogna](https://avatars.discourse-cdn.com/v4/letter/a/c0e974/32.png) [@Abhinav\_Gogna](https://community.gatling.io/u/Abhinav_Gogna)
#### Post date: [November 27, 2014, 4:10pm UTC](https://community.gatling.io/t/how-to-add-random-string-in-json/1749/2 "2014-11-27T16:10:28Z")

</div>

Here is an article that describes how to create random strings in scala

[http://alvinalexander.com/scala/creating-random-strings-in-scala](http://alvinalexander.com/scala/creating-random-strings-in-scala)

Create the string and set in session. In your exec chain builder call the variable.

Gatling documentation and this forum has everything that you need.

---

<div class="post-metadata">

### Author: ![47saikumar](https://avatars.discourse-cdn.com/v4/letter/4/a9a28c/32.png) [@47saikumar](https://community.gatling.io/u/47saikumar)
#### Post date: [November 27, 2014, 5:54pm UTC](https://community.gatling.io/t/how-to-add-random-string-in-json/1749/3 "2014-11-27T17:54:06Z")

</div>

Thanks…its working…
