Forum Discussion

ashutosh's avatar
ashutosh
Occasional Contributor
6 years ago

JSONPath Match Assertion - Make comparison Case Insensitive

Hi ,

 

I am trying to  Perform a JSONPath Match . 

RegionID in Request is in UpperCase (this data is pulled from another SQL data source test step which represents the values in upper case)

API Request :   GET https://URL?regionId=00000-0000-0ABC123

 

The API response is in Lowercase.

API Response : 

 

[
{
"Message" : null,
"RegionId" : "00000-0000-0abc123",
"Region" : "USA",
"ShortForm" : "USA",
"IsActive" : true,
"DateCreated" : "2010-05-17T12:04:07.513"
}
]

 

 

the Asserion Screenshot is  attached.  How do i make either the API Response as lowercase or change the SQL response as Uppercase.

 

I am able to perform this assertion using Groovy but i want to utilise the inbuilt functions of ReadyAPI tool.

 

 

  • I fully understand the desire to use the inbuilt functionality of ReadyAPI over Groovy scripting. JSONPath seems quite limited in the functions it implements, so I think you are limited to manipulating the "Expected Result". One way I think you can do his is to take advantage of the fact that in a Property Expansion you can actually execute Groovy Script, thus you can specify your expected result as:

     

    ${=context.expand('${Get RegionID from SQL#RegionID}').toUpperCase()}

    While I know you stated you didn't want to use Groovy, but perhaps this is a simpler alternative to a Script Assertion.

     

    Perhaps someone else might be able to provide a better solution?

     

  • Radford's avatar
    Radford
    Super Contributor

    I fully understand the desire to use the inbuilt functionality of ReadyAPI over Groovy scripting. JSONPath seems quite limited in the functions it implements, so I think you are limited to manipulating the "Expected Result". One way I think you can do his is to take advantage of the fact that in a Property Expansion you can actually execute Groovy Script, thus you can specify your expected result as:

     

    ${=context.expand('${Get RegionID from SQL#RegionID}').toUpperCase()}

    While I know you stated you didn't want to use Groovy, but perhaps this is a simpler alternative to a Script Assertion.

     

    Perhaps someone else might be able to provide a better solution?