Forum Discussion

varnikha's avatar
varnikha
Occasional Contributor
5 years ago
Solved

Unable to create same assertion for JSON Path for same project in Ready API and SOAP UI

Hi All,

 

I have successfully created a suite for REST API in SOAP UI.When I tried executing the Request with assertion as "$id" and when clicking on Test I got "SUCCESS- Response matches the Content".But, when I tried to import same project in Ready API, I landed up with an error stating(InvalidPathException:Illegal character at position 1 expected '.' ).Please find attachment for better understanding.

 

Apprecaite if anyone can help me in resolving this.

 

 

 

  • richie's avatar
    richie
    5 years ago

    Hi varnikha 

     

    I can't see a way around this other than to recreate the assertion in ReadyAPI! that works in SoapUI but doesnt in ReadyAPI!

     

    Essentially if you click on the id attribute and select the 'Assert' >> 'Content' - you will generate your JSONPath Match Assertion form.  The bit in the JSONPath Expression field is the problem.  

     

    Currently the assertion is displaying $id in the JSONPath Expression field - but it needs to display $['id']

     

    If I create an assertion on an attribute that is at the root of an equivalent .json response I have - it generates $['id']

     

    If I delete the square brackets and quote marks so it reads $id - then I generate the 'InvalidPathException:Illegal character at position 1 expected '.' or [' error response

     

    As I say above - I cant see a way around this except to recreate the assertion on the 'id' attribute (and delete the existing failing assertion) in ReadyAPI! if you want it working in ReadyAPI! 

     

    Sorry I couldn't be more help - but that's the only way I see to get it running in ReadyAPI!

     

    cheers,

     

    rich

     

3 Replies

  • richie's avatar
    richie
    Community Hero

    Hey varnikha 

     

    Can you provide the actual .json from the response? - I believe you're getting the warning because the .json parser in ReadyAPI! seems to think you've got malformed .json

     

    $id : 12345 // is considered malformed .json (i.e. not well formed)

     

    you can't just have an id attribute on it's own without being wrapped within an object (e.g. curly braces { }) or array (e.g. square brackets [ ]) - especially as it appears from the screenshot 'id' is at the root level of your .json.

     

    also - you're $id in the screenshot isn't wrapped with single quotes and the square bracket notation for representing .json (JSONPATH) requires single quote marks.

     

    I don't know what  your .json looks like - but if I add in a content match assertion on an attribute that is at the root level of my response - it appears in the JSONPath Expression field is $['id']

     

    Looks like SoapUI is a little less fussy than ReadyAPI!- but thats to be expected!

     

    I ithink the only way to sort is to recreate your assertion - then you won't have this issue

     

    Hope this helps!

     

    cheers

     

    rich

     

    • varnikha's avatar
      varnikha
      Occasional Contributor

      Hi richie,

          

        Thanks for your quick reply.Please find the Response for REST API project suite.

       

      {
      "id" : 12345,
      "category" : {
      "id" : 0,
      "name" : "Puppy"
      },
      "photoUrls" : [ ],
      "tags" : [ ],
      "status" : "available"
      }

       

      Regards,

      Varnikha

      • richie's avatar
        richie
        Community Hero

        Hi varnikha 

         

        I can't see a way around this other than to recreate the assertion in ReadyAPI! that works in SoapUI but doesnt in ReadyAPI!

         

        Essentially if you click on the id attribute and select the 'Assert' >> 'Content' - you will generate your JSONPath Match Assertion form.  The bit in the JSONPath Expression field is the problem.  

         

        Currently the assertion is displaying $id in the JSONPath Expression field - but it needs to display $['id']

         

        If I create an assertion on an attribute that is at the root of an equivalent .json response I have - it generates $['id']

         

        If I delete the square brackets and quote marks so it reads $id - then I generate the 'InvalidPathException:Illegal character at position 1 expected '.' or [' error response

         

        As I say above - I cant see a way around this except to recreate the assertion on the 'id' attribute (and delete the existing failing assertion) in ReadyAPI! if you want it working in ReadyAPI! 

         

        Sorry I couldn't be more help - but that's the only way I see to get it running in ReadyAPI!

         

        cheers,

         

        rich