Forum Discussion
I'm sorry Rao,
I don't quite understand what you mean by
Assign your json to below variable
What string do I place there? And how to I dictate that I only get 2's and 3's? I'm not very literate in groovy scripting. I see that you have two comments regarding meids:
def meids = items.meid
def submitCounts = items.submitCount
log.info meids
Just trying to understand why the meids would be relevant for what I'm trying to accomplish. Can the sample I attached, where I modified your prior script, not be fixed to work in this case? I wanted to get comfortable with modifying that if possible so I can reuse it for different response parameters in other web service calls :)
def jsonString = '''{
"getResubmittedReturnsResult":{
"getResubmittedReturnsIdentificationOut":[
{
"meid":671,
"transID":92556,
"status":"Resubmitted",
"submitCount":"2",
"addedTime":"09/23/2016 14:28:49"
},
{
"meid":671,
"transID":92558,
"status":"Resubmitted",
"submitCount":"3",
"addedTime":"09/23/2016 14:28:52"
}
]
}
}'''
def parsedJson = new groovy.json.JsonSlurper().parseText(jsonString)
def items = parsedJson.getResubmittedReturnsResult.getResubmittedReturnsIdentificationOut
def shouldNotBePresent = [1, 4]
//Currently the value received in submitCount is String type, so coverting to Integer
def submitCounts = items.submitCount.collect { it as Integer}
log.info submitCounts
assert [] == shouldNotBePresent.intersect(submitCounts), "There are unwanted submitCount value present in the response"
sorry for multiple cycles. Hope this helps.
- CByler9 years agoContributor
hmmm
The assertion passes even though I received multiple "submitCount":"1" in my response :(
- nmrao9 years agoChampion Level 3CByler, updated the script in the above reply, did you check it again?
- CByler9 years agoContributor
I tried the new script you provided, this morning. The assertion still passes even when 1's or 4's are present in the response. Any other thoughts? If there is a better way of doing this, like via a manual assertion step, I' m happy to do so. I actually tried to do that first. However, the response contains so many items, it will not display in the Outline tab, only the JSON tab. When I try to do a manual assertion, Ready API just locks up on me after selecting the Source: from the drop menu.
Related Content
- 9 years ago
- 6 years ago
- 6 years ago
- 2 years ago
Recent Discussions
- 18 days ago