Skip to main content

Posts

Featured

Groovy Script for reading json file and post to REST API Request in SOAPUI

//Import groovy JSON
import groovy.json.*



//Read the JOSN File and parse the json arrays
def fileContent = new File('C:\\Office\\records_JSON.json').text
def json = new JsonSlurper().parseText(fileContent)


//opening new file for storing the REST API Response.
File file = new File("C:\\Office\\Response.txt")


//Count the number of records
def lt = json.size()

//Preparing the list of arrays
//def forgivnessMap = [:]
def forgivnessDataMap = [:]



//Loop to POST Forgivness request for number of records
for (i = 0; i <lt; i++)
{

//log.info(json[i])
//log.info(i)
//Mapping the array values to the vaiables
def amt = json[i].amount
def div = json[i].division


//Mapping varaibles to the LIST MAP
forgivnessDataMap.put("amount",amt.toInteger())



//Eliminate the mapping of divisionnumber if its is NULL
if(div != null)
{
forgivnessDataMap.put("div",downPaymentDocuNo)
}

//Preapring the JSON Payload for forgivness
def ForgivnessPayload = new JsonBuilder(forgivn…

Latest Posts

My pom.xml file for Selenium TestNG Maven Project for referance

Best Practices for RestFul API's design

Scrum Meetings

Some use full links for Scrum Process learning:-

My MongoDB Commands Notes