I try to get some data from a web server.
The code is
Dim req As HttpRequest
dim query as string
query="Athens"
req.InitializeGet("http://openweathermap.org/data/2.1/find/name?q="& query)
It works fine.If i try this code
Dim req As HttpRequest
dim query as string
query="Los Angeles"
req.InitializeGet("http://openweathermap.org/data/2.1/find/name?q="& query)
the following error appears
java.lang.IllegalArgumentException: Illegal character in query at index 50: http://openweathermap.org/data/2.1/find/name?q=Los angeles
at java.net.URI.create(URI.java:727)
at org.apache.http.client.methods.HttpGet.<init>(HttpGet.java:75)
at anywheresoftware.b4a.http.HttpClientWrapper$HttpUriRequestWrapper.InitializeGet(HttpClientWrapper.java:322)
at com.cmweather.christos.result._performsearch(result.java:606)
at com.cmweather.christos.result._activity_create(result.java:263)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:165)
at com.cmweather.christos.result.afterFirstLayout(result.java:84)
at com.cmweather.christos.result.access$100(result.java:16)
at com.cmweather.christos.result$WaitForLayout.run(result.java:72)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
at dalvik.system.NativeStart.main(Native Method)
java.lang.IllegalArgumentException: Illegal character in query at index 50: http://openweathermap.org/data/2.1/find/name?q=Los angeles
** Activity (result) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
I find that the problem is the space between Los and Angeles,but i can not find the solution
The code is
Dim req As HttpRequest
dim query as string
query="Athens"
req.InitializeGet("http://openweathermap.org/data/2.1/find/name?q="& query)
It works fine.If i try this code
Dim req As HttpRequest
dim query as string
query="Los Angeles"
req.InitializeGet("http://openweathermap.org/data/2.1/find/name?q="& query)
the following error appears
java.lang.IllegalArgumentException: Illegal character in query at index 50: http://openweathermap.org/data/2.1/find/name?q=Los angeles
at java.net.URI.create(URI.java:727)
at org.apache.http.client.methods.HttpGet.<init>(HttpGet.java:75)
at anywheresoftware.b4a.http.HttpClientWrapper$HttpUriRequestWrapper.InitializeGet(HttpClientWrapper.java:322)
at com.cmweather.christos.result._performsearch(result.java:606)
at com.cmweather.christos.result._activity_create(result.java:263)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:165)
at com.cmweather.christos.result.afterFirstLayout(result.java:84)
at com.cmweather.christos.result.access$100(result.java:16)
at com.cmweather.christos.result$WaitForLayout.run(result.java:72)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
at dalvik.system.NativeStart.main(Native Method)
java.lang.IllegalArgumentException: Illegal character in query at index 50: http://openweathermap.org/data/2.1/find/name?q=Los angeles
** Activity (result) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
I find that the problem is the space between Los and Angeles,but i can not find the solution
Last edited: