Forum Discussion

dfdsgfdgfdg's avatar
dfdsgfdgfdg
New Contributor
12 years ago

Problem populating json variable using REST

Hi,

I need some help please.

I'm trying to create REST tests that will be run automatically each night. For the tests to work some data needs to transferred between the test cases.

I want to transfer an ID from a previous GET test case to a POST test case that uses json. I have tried different ways of getting the data into a property transfer and that works but I can’t figure out how to use that data in a variable in the json request I need to use in the POST test case.

This is my json request where "domain_id" is the variable I'm trying to populate from the previous test case…

{
"name":"Site1",
"language": "en",
"domain":{
"id":${#domain_id}
},
"administrators":[{
"id":140
}]
}

… and this is the raw actual request that is sent from soapU.

{
"name":"Site1",
"language": "en",
"domain":{
"id":
},
"administrators":[{
"id": 140
}]
}

As you can see the first “id” field is empty. I’ve tried different ways of using the variable “domain_id” as shown below but it always ends up empty.

${#TestCase#domain_id}
${domain_id}
${#domain_id}

This is very close to what is described in the links below but I still cannot get it to work.
viewtopic.php?f=14&t=11065&p=38878&hilit=json#p38878
viewtopic.php?f=5&t=12073&p=33153&hilit=json+rest#p33153

I'm hoping for a detailed answer with examples of how to configure the property transfer and how to use that data in a variable in a json request. I have tried to pro version of soapUI as well but the problem remains. I'm using soapUI 4.5.1 on Server 2008 R2 (x64).

If you need more information just ask!

3 Replies