cancel
Showing results for 
Search instead for 
Did you mean: 

Ready! API - How to dynamically add collection objects to Soap request

Web
Visitor

Ready! API - How to dynamically add collection objects to Soap request

I am trying to automate requests for Order from the data available in the Database

 

Find below the elements in the request. It contains item collection which needs to dynamically modified based on the data available in the Database

Request with two items

 

<orderRequest> 
<orderTimestamp> 
<!--1 or more repetitions:-->
<items>
<item>
</itemName>
</quantity>
</unitPrice> 
</item>
<item>
</itemName>
</quantity>
</unitPrice> 
</item>
</items> 
</orderRequest> 

The number of items for an order is defined by the number of rows available in the Database for a given orderID. 

 I am using DataSource/DataLoop step but the problem I am having is it creates multiple requests for same orderID with one item each. 

 

For Example purpose, I have taken sample values for two order
Step 1: DataSource Step.
Count in the first column defines the number of item for a given Order ID. Essentially the number of Item Collection to be added

xdm11

 

Step 2: The SOAP Request Step - The elements value are directly mapped to the Datasource Step's column. However as indicated above, we would need to add the collection based on the number of items for a given order
Ex: Order ID 1 has 2 items, Order ID 2 has 4 items. So two requests have to made, one with 2 item and second with 4 items. Currently though I have mapped it directly

<orderRequest> 
<orderTimestamp>${OrderData#orderTimestamp}</orderTimestamp> 
<!--1 or more repetitions:-->
<items>
<item>
<itemName>${OrderData#itemName}</itemName>
<quantity>${OrderData#quantity}</quantity>
<unitPrice>${OrderData#unitPrice}</unitPrice>
</item>
</items> 
</orderRequest>

Step 3: DataSource Loop Step - This essentially loops through the above two steps for all data in the Datasource Step. So if I run as is, it will make 6 requests with one item each

 

Is there a way I can create dynamic request using the operations/functions available in Ready! API 

 

1 REPLY 1
Staff

Re: Ready! API - How to dynamically add collection objects to Soap request

Hi,

 

This is not possible out of the box. you need to add a groovy script testStep which will check number of items present and create the item node,

<item>
</itemName>
</quantity>
</unitPrice> 
</item>
<item>

save it in a property and add that property in request.

Thanks

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: