Android Question Httpjob java error calling job.postString

Gnappo jr

Active Member
Licensed User
Longtime User
I apologize in advance if I'm wrong in entering the post, or if there is already a solution I did not look good in the forum.
I have an error with job.postString

'B4a version 5.02(1) + UttpUtils2 version 2.01

Sub Globals
Private ServerUrl As String="http://192.168.0.50/webform1.aspx" & "?query=" & "select count(adulti) as TotPersone FROM Prenotazioni"
'This work ==> Private ServerUrl As String=""http://192.168.0.50/webform1.aspx"
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("TABLEAU")
End Sub

Sub Activity_Resume

Dim job As HttpJob
job.Initialize("Job0", Me)
job.PostString(ServerUrl,"") ' <==== LINE ERROR
job.GetRequest.Timeout=2000
End Sub


ERROR:
java.lang.IllegalArgumentException: Illegal character in query at index 46:
http://192.168.0.50/webform1.aspx?query=select count(adulti) as TotPersone FROM Prenotazioni


Calling http://192.168.0.50/webform1.aspx?query=select count(adulti) as TotPersone FROM Prenotazioni with browser Firefoxwork the server responding fine: [{"TotPersone":1}]

Any help is appreciated
Best regards
Gnappos
 

KMatle

Expert
Licensed User
Longtime User
It looks like your server script needs a GET request, so the call looks like this:

B4X:
Job.Download2("http://192.168.0.50/webform1.aspx",  _
                     Array As String("query", "select count(adulti) as TotPersone FROM Prenotazioni"))

Take a search (Google or here) for GET and POST requests.

By the way: Be careful as anyone can send any request to that script (one could send a "Delete from Prenotazioni" and your table is empty). Use RDC or just send only data to your scripts and encrypt it.
 
Upvote 0

Gnappo jr

Active Member
Licensed User
Longtime User

I resolved, the problem was due to the presence of invisible abnormal characters in the query blank. I deleted them and reinserted and everything worked.
If it can be useful to someone the problem originated in copying and pasting from a query of sql managent studio form.
Thanks to KMatle for the precious advice that has allowed me to come to the fore and that is a good reason for me to study.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…