Forum Discussion

mgroen2's avatar
mgroen2
Super Contributor
8 years ago

How to assert on value in a Json response?

Hi,

what would be the code to assert the value of "accesstoken" = " 1234"  in Soap UI?

 

Which of the available Assertions do I need to pick (I guess XPath match, but not sure)?

 

and what would be the Regex?

 

Thanks for the help.

 

  • nmrao's avatar
    nmrao
    Champion Level 3
    For the mentioned case, JsonPatMatch is fine.

    $.accessToken should equal to the desired value.
    • mgroen2's avatar
      mgroen2
      Super Contributor

      nmrao wrote:
      For the mentioned case, JsonPatMatch is fine.

      $.accessToken should equal to the desired value.

      nmraoI entered this (see screenshot), but it's not working. as you can see there is an accesstoken in the response, but validating it gives an error (it thinks it should be false?). Do you have any tips?

       

      • HKosova's avatar
        HKosova
        SmartBear Alumni (Retired)

        mgroen2, you're using JsonPath Regex Match. Try the regular JsonPath Match instead.