Read file for json data, printIn , possible to parse the println response as input to object HTTP body?

import static org.assertj.core.api.Assertions.*

import com.kms.katalon.core.configuration.RunConfiguration

import groovy.json.JsonOutput as JsonOutput
import groovy.json.JsonSlurper as JsonSlurper
import java.io.File

String fileContents = new File(RunConfiguration.getProjectDir() + “/Data Files/test.json”).getText(‘UTF-8’)

def jsonSlurper = new JsonSlurper()
def jsonObject = jsonSlurper.parseText(fileContents)

println JsonOutput.prettyPrint(fileContents)

===> possible to parse the println response as input to object HTTP body?

1 Like

Why don’t you simply send the fileContent in the body?
Jsonslurper will cast the string content in an object. Usefull for checking keys/values and so on.
But the body of an http request need the json as a string, which you already have it when you read the file.

how to send the fileContent in body? that is my question.
something like setBodyContent or HttpTextBodyContent ??? what is the correct syntax to be used in Katalon test case?