invalidArgumentException

in Xojo, the code below ALWAYS throws an Exception at runtime, But I can paste Sql line into browser and it works fine. I think I saw someone else on the forum had a similar issue but I never saw a resolution. Does anyone have any ideas, much appreciated.

Roger

M1 Mac OS 12.2.1
Xojo 2021 3.1

Sql = "https://www.xxxxxx.com/file_name.php?db="+Sql

try
  tmpString = netConnect.SendSync("GET", Sql,  30) < - Error Here !
      
 // netConnect is a URLConnection

Catch err As InvalidArgumentException
  MessageBox(err.message + " Error No.: " + err.ErrorNumber.ToString)
  
end try

What is Sql before the assignment?

Can you hardcode the value and try it?

Try wrapping your Sql variable with https://documentation.xojo.com/api/text/encoding_text/encodeurlcomponent.html like so:

Sql = "https://www.xxxxxx.com/file_name.php?db="+EncodeURLComponent(Sql)

When you paste something into a browser address bar, typically a browser will automatically add URL Encoding for you (even though the browser may not show the encoding, i.e., Safari). The encoding will ‘escape’ characters like spaces and special or reserved characters that are not compatible with a URL. Your code example does not show any of that work being done before calling SendSync.

THANK YOU SCOTT !!! That worked . I Have been butting my head trying to figure this out… Thank You…

1 Like