Method Community

 

MethodAPISelect_XMLV2 where clause

Last post 03-19-2012 7:41 AM by Method_Paul. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 03-16-2012 12:19 PM

    • viret56
    • Top 75 Contributor
    • Joined on 01-10-2012
    • Virginia
    • Posts 79

    MethodAPISelect_XMLV2 where clause

    I am using PHP CURL to request data using MethodAPISelect_XMLV2.  I am making successful requests until I try using LIKE in the where clause.  For example, if I use

              strWhereClause=RefNumber = '123'

    data is retrieved.

    If, however, I use

              strWhereClause=RefNumber like '%123%'

    no data is retrieved (and no errors either).

    Is it possible to make MethodAPISelect_XMLV2 calls using LIKE in the where clause?  If so, why is the syntax I am using not working?

     

  • 03-16-2012 12:25 PM In reply to

    • viret56
    • Top 75 Contributor
    • Joined on 01-10-2012
    • Virginia
    • Posts 79

    Re: MethodAPISelect_XMLV2 where clause

    I think I have answered my own question.  When I hard code '%' into the where clause, I get no data.  If I include '%' as part of the search parameter typed into the form, I get data.

    I am not sure why there is a difference in the results, but at least I can move forward.

     

  • 03-16-2012 12:48 PM In reply to

    • viret56
    • Top 75 Contributor
    • Joined on 01-10-2012
    • Virginia
    • Posts 79

    Re: MethodAPISelect_XMLV2 where clause

    Answer

    Now I realize what is happening.  The '%' followed by numbers is being intrepreted as a URL encoded entity.  I need to URL encode the '%' with '%25'.  Now I am retreiving what I expected.

  • 03-19-2012 3:30 AM In reply to

    Re: MethodAPISelect_XMLV2 where clause

    Good show.  And good clarification, Paul.  When using MethodAPI via POST, I pass the values on the right sides of '=' signs through the PHP function urlencode().

    Slightly off-topic, don't forget to prefix quotes with slashes if comparing arbitrary strings.  I'm guessing that applies to .NET or any language.

  • 03-19-2012 7:41 AM In reply to

    Re: MethodAPISelect_XMLV2 where clause

    Thanks viret576 for sharing.

    To anyone else reading this, it does depend on what technology you are using whether you need to URL encode or not.  For example, if you are using .NET and adding a web reference, the URL encoding is automatically handled for you.   But if you are doing a raw HTTP Post (which the Method API supports), then you'd of course need to do URL encoding.

    Paul

Page 1 of 1 (5 items)