Ask a Question

How to assign a value to a variable in the Request JSON body

RealNetworks
Occasional Contributor

How to assign a value to a variable in the Request JSON body

I have come to a situation where I need to assign a unique value to an email 'field' REST Request JSON body. I am supposing I will need to write a script to do so but how?

Here's how my json body looks like:
{
"first_name": "testLoadFirstName",
"last_name": "testLoadLastName",
"username": "testloaduser6@merc.com",
"email": "testloaduser6@merc.com",
"password": "WnBaUEFlVk82VktnU2k2QG1lcmN1cnliZXRhLmNvbQ==",
"tos_agree": "true",
"device_id": "loadDeviceId1",
"device_user_agent": "loadTestUserAgent1",
"device_name": "loadTestDeviceName"
}

The value for the email can be something like this:

java.util.UUID.randomUUID() + '@merc.com'


Any help will be highly appreciated. Please let me know if you need any further info. Thanks in advance!
2 REPLIES 2
RealNetworks
Occasional Contributor

Re: How to assign a value to a variable in the Request JSON

Never mind. I found a solution. It could be a potential SoapUI bug that it was not showing the request JSON body from the correct request. It was always picking the GET request although I had explicitly selected the POST request from the drop-down. After I deleted the GET request, it started showing the JSON body when added to a TestCase. Then, I could simply use the Groovy Script to generate the unique email address every time.

Re: How to assign a value to a variable in the Request JSON

Hi,

Thanks for the information. I'm glad to hear you solved your issues. We'll try to reproduce this to see whether or not it's a bug, and if it is we'll log it in our bug tracking system.

Let us know if you need assistance in the future.

Regards,

Arian
SmartBear Sweden

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: