# Request body in json array format in post request

**URL:** <https://forum.katalon.com/t/request-body-in-json-array-format-in-post-request/12397>\
**Category:** API Testing\
**Tags:** api-testing, katalon-studio\
**Created:** [August 5, 2018, 12:56am UTC](https://forum.katalon.com/t/request-body-in-json-array-format-in-post-request/12397 "2018-08-05T00:56:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kat1](https://avatars.discourse-cdn.com/v4/letter/k/cdc98d/32.png) [@Kat1](https://forum.katalon.com/u/Kat1)\
**Post date:** [August 5, 2018, 12:56am UTC](https://forum.katalon.com/t/request-body-in-json-array-format-in-post-request/12397/1 "2018-08-05T00:56:52Z")

</div>

Hi Experts,

I have a task in which my json object eg Student consists of an array for Student Info.  
Info can repeat as many times inside Student. I want to take test data from excel sheet and pass the request body in my post request. Could you help me in formation of excel sheet and how to use the array in my request object.

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [August 6, 2018, 3:09am UTC](https://forum.katalon.com/t/request-body-in-json-array-format-in-post-request/12397/2 "2018-08-06T03:09:29Z")

</div>

Hello Kat,  
do you really store such structure in excel?  
Usually what i do in case of complex structures - i have kind of template and based on that template i generate programmatically data i need. e.g. :  
name - random string, date of birth - random date from range, class - random pick from range etc.  
on parameter that will be used as unique key i usually add timestamp so i’ll be able to execute test as many times as i want.  
in case i need i store generated data in db, but usually i need those data only once per TC so no storage except in variables is needed.

---

<div class="post-metadata">

**Author:** ![Kat1](https://avatars.discourse-cdn.com/v4/letter/k/cdc98d/32.png) [@Kat1](https://forum.katalon.com/u/Kat1)\
**Post date:** [August 6, 2018, 4:40am UTC](https://forum.katalon.com/t/request-body-in-json-array-format-in-post-request/12397/3 "2018-08-06T04:40:43Z")

</div>

Can you provide me with a sample code how to pass JSON array in the script in Katalon studio.Thanks for your suggestion of generating on the fly.

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [August 6, 2018, 5:36am UTC](https://forum.katalon.com/t/request-body-in-json-array-format-in-post-request/12397/4 "2018-08-06T05:36:03Z")

</div>

example how to work with json (one of many ways)

```auto
import groovy.json.JsonSlurperdef slurper = new groovy.json.JsonSlurper()def jsonDefText = '{ "name": "John", "surname": "Doe", "options" :[{"setOption1":"valOfSetOption1_1", "setOption2":"valOfSetOption2_1","setOption3":"valOfSetOption3_1"},{"setOption1":"valOfSetOption1_2", "setOption2":"valOfSetOption2_2"}]}' def jsonVar = slurper.parseText(jsonDefText)println jsonVar assert jsonVar.name == "John"assert jsonVar.options[0].setOption1 == "valOfSetOption1_1"assert jsonVar.options[1].setOption2 == "valOfSetOption2_2"try{	assert jsonVar.options[1].setOption3 == "valOfSetOption3_2"} catch (org.codehaus.groovy.runtime.powerassert.PowerAssertionError pae){	println pae	println "There is no such element as: jsonVar.options[2].setOption3"}jsonVar.options[1].setOption3 = "valOfSetOption3_2"try{	assert jsonVar.options[1].setOption3 == "valOfSetOption3_2"} catch (org.codehaus.groovy.runtime.powerassert.PowerAssertionError pae){	println pae	println "There is no such element as: jsonVar.options[2].setOption3"}

```
