Forum Discussion

piyu_sarda's avatar
piyu_sarda
Occasional Contributor
9 years ago
Solved

SOAP UI 5.2 is throwing JSON invalid error while property transfer although JSON is valid

Hi,

I am getting proper collection JSON response as part of Rest API call. I have validated it using jsonlint.com. But when i am performing a property transfer from Response to next request, SOAP UI 5.2 gives me invalid JSON.

 

Could anyone please help? I have attached only the structure of my JSON response and have removed the values.

 

Thanks

  • Finally I succeeded with this configuration.

     

    Thanks.

16 Replies

    • TanyaYatskovska's avatar
      TanyaYatskovska
      SmartBear Alumni (Retired)

      Hi Piyu_sarda,

       

      If you provided us with a sample project where this issue is reproduced, I would pass it to our Dev Team so that they could investigate this.

       

      • piyu_sarda's avatar
        piyu_sarda
        Occasional Contributor

        Hi Tanya,

         

        Finally after a good number of hours, I came to know the root cause of this issue. The response JSON contains a empty line at the top which SOAP UI is not able to process. Although the JSON view of Response in the Test Step shows a valid JSON but when performing a property transfer, it looks like it is picking up from raw response which has an empty line at the top. My dev team is not going to definitely fix this in a shorter term as the our APIs are used by other applications and no one complained about it.

         

        Is there a way in SOAP UI to get around it? I have replicated this issue with a sample project. Do you still need it or the details are sufficient to replicate this?

         

        Thanks,

        Piyu

    • piyu_sarda's avatar
      piyu_sarda
      Occasional Contributor

      Hi ,

       

      I should be able to extract any value. For now you can look into href element under collection.

       

      Thanks

      • nmrao's avatar
        nmrao
        Champion Level 3

        Have you looked into the sample provided

  • nmrao's avatar
    nmrao
    Champion Level 3

    May be you can use script assertion to see if that works as posted in

    http://community.smartbear.com/t5/SoapUI-Open-Source/View-Assertion-Value-in-SoapUI/m-p/105064#U105064

     

    You may need, additionall statement, to set the test case property in order to be able to use the retrieved value from the response to other steps

     

    If you look at the above thread value retrieved is in expectedValue variable.

     

    The same value is need another (from your description as you are doing property transfer), add below line of code at the end:

    context.testCase.setPropertyValue('PROPERTY_NAME', expectedValue)

    and use property expansion in the later steps as ${#TestCase#PROPERTY_NAME}

  • migueleis's avatar
    migueleis
    New Contributor

    I have same problem getting properties from JSON with SoapUI 5.2.0. This is my response object 

    {
    "code": 0,
    "message": "OK",
    "sessionId": "3122d0bd-9f21-400a-b95d-87217adeab02"
    }

     

    When try to get one of them from property tranfer (Property: ResponseAsXml; Path language: JSONPath) I have error: 

     

    Mon Sep 21 13:42:34 CEST 2015 sessionID [Invalid JSON: <Response xmlns="http://localhost/...">
    <code>0</code>
    <message>OK</message>
    <sessionId>3122d0bd-9f21-400a-b95d-87217adeab02</sessionId>
    </Response>]

    • nmrao's avatar
      nmrao
      Champion Level 3
      You can see the response as JSON. So, you may use the sample provided to extract the value using script assertion.
  • migueleis's avatar
    migueleis
    New Contributor

    Finally I succeeded with this configuration.

     

    Thanks.