Unable to parse Json response

Hi Team,

I have an issue while parsing a response file with Jsonslurper :
in the object repository I can get the response file. If I read it with Json Path Finder, I get : x[2].ope_id for the data I need to use in my script.

My script for the test case is :
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable
import groovy.json.JsonSlurper

loginResponse = WS.sendRequest(findTestObject(‘Cobalt/Remboursement une transaction/Acquisition de ope_id des transactions’))

def slurper = new JsonSlurper()
def result = slurper.parseText(loginResponse.getResponseBodyContent())
def value = result.x[2].ope_id

and this is the log :
Test Cases/Cobalt/Reboursement transaction/TC - Remboursement transaction - Copy FAILED.
Reason:
java.lang.NullPointerException: Cannot get property ‘ope_id’ on null object
at TC - Remboursement transaction - Copy.run(TC - Remboursement transaction - Copy:24)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:398)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:389)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:368)

I really don’t know what’s wrong.

Katalon version : 7.9.0

thanks !

you can add a println result statement in your code to see what is the response you get.

@alexandre.thibaud-ex thanks for sharing …
its the second value from array list open_id which you need to map can you try below or println(result) to know the response if possible as bionel said

def value = result[2].ope_id
println(value)

@alexandre.thibaud-ex did it work out for you ?