Forum Discussion

bqualters's avatar
bqualters
Occasional Contributor
2 years ago

Trying to figure out how to do script assertions and copied this code from other post and get error

//imports
import groovy.json.JsonSlurper

 

//grab the response
def ResponseMessage = messageExchange.response.responseContent

 

// replace "(starting&ending), [](starting&ending) and \ with space from response
def TrimResponse =ResponseMessage.replaceAll('^\"|\"$','').replaceAll('^\\[|\\]$','')replaceAll('\\\\','')

 

//define a JsonSlurper
def jsonSlurper = new JsonSlurper().parseText(TrimResponse)

 

//verify the slurper isn't empty
assert !(jsonSlurper.isEmpty())

 

The Request returns an ERROR as expected but I was trying to do a string content check on the error message - seems I can't do that as it can't parse the file I guess...any help?  KEEP IN MIND - I AM A NEWBIE!

 

Error message returned by script is-->

Unable to determine the current character, it is not a string, number, array, or object The current character read is 'I' with an int value of 73 Unable to determine the current character, it is not a string, number, array, or object line number 1 index number 0 Invalid CASEID: 9999999999 ^

No RepliesBe the first to reply