# generate body for each user from function

**URL:** <https://community.gatling.io/t/generate-body-for-each-user-from-function/4637>\
**Category:** Gatling (Open-Source)\
**Created:** [November 12, 2018, 12:47pm UTC](https://community.gatling.io/t/generate-body-for-each-user-from-function/4637 "2018-11-12T12:47:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martijn\_Kuypers](https://avatars.discourse-cdn.com/v4/letter/m/ebca7d/32.png) [@Martijn\_Kuypers](https://community.gatling.io/u/Martijn_Kuypers)\
**Post date:** [November 12, 2018, 12:47pm UTC](https://community.gatling.io/t/generate-body-for-each-user-from-function/4637/1 "2018-11-12T12:47:00Z")

</div>

Hey guys,

I have a function that creates an xml body.  
I’d like to adjust my scenario in a way that my function gets called each iteration for each user to have a unique body each time.

Is this possible?

I’ve tried calling the function in .body but the problem is that some variable generated in the function also need to be put in the API url.

for example

`  
def potato :String{  
a = r.nextInt(10000000)

a + b = potato  
return potato  
}

`

so potato will be part of the body but I need “a” in my url like /potatoes/a

is there a step in scenarios I can do before the api call to generate this value?
