Forum Discussion

mpw83's avatar
mpw83
Contributor
5 years ago
Solved

Getting 'Malformed escape pair' for '%' in query parameter

I am trying to filter some Id's in my query using Like '%Collections%' . I am sure the SQL is correct and working. But in SoapUI request I am getting `Malformed escape pair at index 202:`. S...
  • richie's avatar
    richie
    5 years ago

    Hi mpw83 

     

    I'm such an idiot sometimes - you told me the problem - I really dont know what I was thinking.  

     

    Its the percent encoding - you are using the SQL wildcard % in your query - but % is a reserved character in HTTP - so you can't just use it like you have (this is why quite often when representing SQL query hits like this, RESTful requests replace the % wildcard with an alternative so this isn't a problem

     

    Anyway - if you go into Projects and view either the method or resource - click on any parameter (header, query, template) to enable the functionality - at the bottom there is a checkbox that relates to disabling the URL/percent encoding.  I've never used this before but I suspect this will do what you need so ReadyAPI! doesn't trap your request - see the following screenshot

    An An alternative to disabling the percent encoding is to escape the % char in yoru request.

     

    %'s escape sequence is %25 - so if you replace '%Collections%' with '%25Collections%25' that should work.

     

    I encoded your whole URI query string - so 

     

    q=select+id+from+loan__Bank_Account__c+where+loan_ffa__Payment_Mode__c+=+'a5C90000000YaLxEAK'+and+loan__Bank_Name__c+LIKE+'%Collection%'

    encodes as the following:

     

    q%3Dselect%2Bid%2Bfrom%2Bloan__Bank_Account__c%2Bwhere%2Bloan_ffa__Payment_Mode__c%2B%3D%2B%27a5C90000000YaLxEAK%27%2Band%2Bloan__Bank_Name__c%2BLIKE%2B%27%25Collection%25%27

     

    Hope this helps,

     

    cheers,

     

    rich