How to generate GUID using JMeter?
- Add Recording Controller to the Thread Group
Right-click on Thread Group -> Add -> Logic Controller -> Recording Controller
![](https://systems.axonator.com/wp-content/uploads/2022/04/image-23-1024x549.png)
2. Add Beanshell Sampler to the Recording Controller.
Right-click on Recording Controller -> Add -> Sampler -> BeanShell Sampler
![](https://systems.axonator.com/wp-content/uploads/2022/04/image-24-1024x544.png)
3. Add the below script to the BeanShell Sampler-
vars.put(“afoid”, “${__UUID}”.replace(“-“, “”));
afoid – it is as variable name
replace function is used to remove “-” from the generated GUID.
![](https://systems.axonator.com/wp-content/uploads/2022/04/image-25-1024x547.png)
Replace all the actual afoid with these above variables in your JSON.
Example- “${afoid}”
{
"ao": [
{
"afoid": "${afoid}",
"fid": 234579,
"ff": [
{
"type": "groupheader-widget",
"prompt": "Group Header 7",
"identifier": "Group_Header_10",
"sub_type": "label",
"value": ""
}
}
You can check this generated GUID in the request section of the HTTP Request under Listeners in JMeter
![](https://systems.axonator.com/wp-content/uploads/2022/04/image-26-1024x543.png)
0 Comments