Forum Discussion

Adrian-Pail's avatar
Adrian-Pail
New Contributor
6 years ago

Strange error

Hello!

 

I want to extract a resopnse from a previous test and to use it in the next test. 

 

This is the code: 

 

import groovy.json.JsonSlurper
import com.eviware.soapui.support.types.StringToStringMap
import groovy.json.JsonOutput

responseContent = testRunner.testCase.getTestStepByName("CreateGroup").getPropertyValue("response")
slurperresponse = new JsonSlurper().parseText(responseContent) //this is the line where the erroe occurs
def confId = slurperresponse.response.toString()
log.info confId

testRunner.testCase.getTestStepByName("DeleteGroup").testRequest.setPropertyValue("groupId", confId)

 

However when I try to run it an pop-up error appears "groobj.json.internal.Exception$JsonInternalException: unexpected character d" (there's no d charachter at that line and this makes me very confused) 

 

I've saved the code and I've even restarted the aplication.

 

I don't have much experience with this application but I'm sure this is not normal

6 Replies

  • Radford's avatar
    Radford
    Super Contributor

    I think the code looks OK, I would guess that the issue is that there is something wrong with the JSON data. I would add the line:

     

    log.info responseContent

    before your parse text line, see exactly what it is trying to parse. Is it what you expect and can you independently confirm (outside of Ready API) the text string is valid JSON data?

     

    • Adrian-Pail's avatar
      Adrian-Pail
      New Contributor

      Thank you for your answer, I've figure it out after I read your message, it was quite a silly mistake

      • mcp111's avatar
        mcp111
        Contributor

        Can you please post the solution?

         


        Adrian-Pail wrote:

        Thank you for your answer, I've figure it out after I read your message, it was quite a silly mistake