Android Question GET request with JSON object as a parameter

RhodesB4A

Member
Licensed User
Longtime User
Hi,

So I'm trying to perform a GET request but I keep getting the error below. It seems to be complaining about the first "{" brace. The GET request expects the URL with parameters in the form of e.g www.url.com/{"name": "Home Alone 3"} which then deletes the row with name "Home Alone 3". Works just fine via desktop so I assume my code is wrong.
"
java.lang.IllegalArgumentException: Illegal character in path at index 86: http://xxx.xxx.xxx.xxx:xxxx/reedhousesystems-its-africa-web/service/art/remove-product/{"name":"Number 9"}

** Activity (main) Create, isFirst = true **
main_remprodontw (B4A line: 134)
remProdJob.InitializeGet(remProdUrl)
java.lang.IllegalArgumentException: Illegal character in path at index 86: http://xxx.xxx.xx.xxx:xxxx/reedhousesystems-its-africa-web/service/art/remove-product/{"name":"Number 9"}
at java.net.URI.create(URI.java:776)
at org.apache.http.client.methods.HttpGet.<init>(HttpGet.java:75)
at anywheresoftware.b4a.http.HttpClientWrapper$HttpUriRequestWrapper.InitializeGet(HttpClientWrapper.java:306)
at com.exg.send2me.main._remprodontw(main.java:707)
at com.exg.send2me.main._activity_create(main.java:269)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at com.exg.send2me.main.afterFirstLayout(main.java:89)
at com.exg.send2me.main.access$100(main.java:16)
at com.exg.send2me.main$WaitForLayout.run(main.java:74)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)"
 

Attachments

  • err.JPG
    33.2 KB · Views: 324
Last edited:

RhodesB4A

Member
Licensed User
Longtime User
thanks for reply. Could you provide me with snippet code on how to this? I have tried but to no avail
 
Upvote 0

RhodesB4A

Member
Licensed User
Longtime User
The entire code runs but the JobDone event returns :

"JobName = RemProd, Success = false
Error: Method Not Allowed"

The server side is configured for a GET that deletes so I don't understand the problem?

B4X:
Sub RemProdOnTW

    Dim RemProd As HttpJob
    Dim remProdUrl As String
   
    RemProd.Initialize("RemProd", Me)
  

    'remProdUrl = "http://146.231.88.170:8080/reedhousesystems-its-africa-web/service/art/remove-product/"
    remProdUrl = "http://146.231.88.170:8080/reedhousesystems-its-africa-web/service/art/remove-product/" '& JSONGenerator.ToString()
    RemProd.Download2(remProdUrl,Array As String("{name:", "Mandela}"))  

    RemProd.GetRequest.SetHeader("Accept","application/json")


End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…