cancel
Showing results for 
Search instead for 
Did you mean: 

create list of object in one Rest request

SOLVED
New Contributor

create list of object in one Rest request

Hi everbody, 

 

am new to SOAPUI & GROOVY Script, 

 

I would like to create a request test with a list of object "car" in one REST request.

I'm able to read raw from excel file and I don't know how to create the request with groovy code and save the result in a file.

 

Here the request definition  (Json form) :

{
"idCar" : "string",
"idUser" : "string",
"idTypeCar" : "string",
categories : [

{ "idCategorie" : "string", 

   "nameCategorie": "string"}

]

}

 

I need to send a request like : 

{

{
"idCar" : "id1",
"idUser" : "0",
"idTypeCar" : "Immatriculé",
categories : [

{ "idCategorie" : "id01", 

   "nameCategorie": "cat01"}

{ "idCategorie" : "id02", 

   "nameCategorie": "cat02"}

]

}

 

{
"idCar" : "id2",
"idUser" : "2",
"idTypeCar" : "Immatriculé",
categories : [

{ "idCategorie" : "id02", 

   "nameCategorie": "cat02"}

{ "idCategorie" : "id03", 

   "nameCategorie": "cat03"}

]

}

}

 

Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: create list of object in one Rest request

That is not the appropriate way here to create single request with all the rows.

There is a related question in the forum for the same but for generating soap request. One can build json request as well.
https://community.smartbear.com/t5/SoapUI-Pro/How-to-Generate-a-Request-Body-Based-on-Data-from-Data...


Regards,
Rao.

View solution in original post

6 REPLIES 6
Community Hero

Re: create list of object in one Rest request

Would you mind showing how the data is structured in the data source file? A sample file attachment or a screen shot possible?


Regards,
Rao.
New Contributor

Re: create list of object in one Rest request

Hi,

 

Thank you for your response @nmrao ,

 

The data source is an excel file of 5 columns ("idCar",  "idUser", "idTypeCar",  "idCategorie", "nameCategorie"). To read the file, I created a dataSource and a datasource Loop to iterate in each row and initiate the properties corresponding to each Json element.

 

Regards,

lamiae

Community Hero

Re: create list of object in one Rest request

That is not the appropriate way here to create single request with all the rows.

There is a related question in the forum for the same but for generating soap request. One can build json request as well.
https://community.smartbear.com/t5/SoapUI-Pro/How-to-Generate-a-Request-Body-Based-on-Data-from-Data...


Regards,
Rao.

View solution in original post

New Contributor

Re: create list of object in one Rest request

I want to send a request to create many "Car" objects in one time. so I need to send in one request the list of these cars like : 

[

{ car1 data,

}

{ car2 data,

}

{car3 data

}

]

regards,

lamiae

Community Leader

Re: create list of object in one Rest request

@lamiae :

 

What challenge are you facing while creating the json and also how much coding part you have done.


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
Community Manager

Re: create list of object in one Rest request

Thank you everyone for trying to help here. 

 

@lamiae please let us know which issue exactly you are facing? Is there a piece of code you could share that is troublesome that the Community could take a look at and fix? 


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors