i am trying to use jenkins pipeline to show API payload, on the ApiUrl1 runs normally without problems, but on the APiURL2 show that error is Error occurred: java.io.NotSerializableException: groovy.json.internal.LazyMap
try{
final String response = sh(script: """curl -svf --globoff --request GET --header "Authorization: Bearer ${token}" "$apiUrl" """, returnStdout: true).trim()
// Parse API response
def jsonSlurper = new groovy.json.JsonSlurper()
def result = jsonSlurper.parseText(response)
String testingResponse = result.toString()
echo testingResponse
def payload = result.data
for (def jobTitleList in payload) {
def jobTitleName = jobTitleList.job_title_id.job_title
jobTitles << jobTitleName
}
//def jobTitles = payload.collect { it.job_title_id.job_title }
echo "${jobTitles}"
for (def jobTitleName in jobTitles) {
String jobTitleString = jobTitleName.toString()
echo "Job Title : ${jobTitleString}"
echo apiUrl2
try {
echo "Line 87"
// Execute curl command to fetch data
final String response2 = sh(script: """https_proxy=http://{proxy}curl -svf --globoff --request GET --header "Authorization: Bearer ${token}" "${apiUrl2}" """, returnStdout: true).trim()
echo "Line 91"
// Parse API response
def result2 = jsonSlurper.parseText(response2)
String testingResponse2 = result2.toString()
echo testingResponse2
} catch (Exception e) {
echo "Error encountered while fetching data"
echo "Error message: ${e.message}"
}
}
} catch(e) {
echo "${e.message}"
echo "No PIC"
}
return jobTitles
}