Android Question Json reading difficulties

cirollo

Active Member
Licensed User
Longtime User
Hi!
I'm having some problems reading a JSON.

I've 2 ws, called GetUser and GetAlunni, this how I consume them:

GetUser
B4X:
....
    ' "consumiamo" il WS
   Dim job1 As HttpJob
   job1.Initialize("Job1", Me)
   'Send a GET request
   job1.Download("http://myip.it:3015/special/GetUser?USERWEB='"&TxtUser.Text.Trim&"'&PWDUWEB='"&TxtPassword.Text.Trim&"'")
....

Sub JobDone (Job As HttpJob)
   Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
   Log(Job.ErrorMessage)
   If Job.Success = True Then
       Dim res As String
       res = Job.GetString
       Log("Back from Job:" & Job.JobName )
       Log("Response from server: " & res)
       ' facciamo il parsing del json ricevuto
       Dim parser As JSONParser
       parser.Initialize(res)
       Dim root As List = parser.NextArray
       For Each colroot As Map In root
           USERWEB = colroot.Get("USERWEB")
           PWDUWEB = colroot.Get("PWDUWEB")
           DBNAME = colroot.Get("DBNAME")      
           Log("USERWEB = "&USERWEB.Trim&" ("&TxtUser.Text.ToUpperCase&") - PWDUWEB = "&PWDUWEB.Trim&" ("&TxtPassword.Text.ToUpperCase&") - DBNAME = "&DBNAME.Trim)
       Next
       If USERWEB.trim = TxtUser.Text.trim.ToUpperCase And PWDUWEB.trim = TxtPassword.Text.trim.ToUpperCase Then
           ok_procedi = True
       End If
   Else
       Log("Error: " & Job.ErrorMessage)
       Msgbox(Job.ErrorMessage,"Errore")
       ok_procedi = False
   End If
   Job.Release
   ProgressDialogHide
   Log(ok_procedi)
   ' se ho dei dati procedo
   If ok_procedi = True Then
       Activity.Finish
       StartActivity(Studenti)
   End If

ws response:
[{"USERWEB":"10028 ","PWDUWEB":"WEBBAACI ","DBNAME":"FS_SCHOOL"}]

I'm able to read this Json!

GetAlunni
B4X:
....
    Dim job1 As HttpJob
   job1.Initialize("Job1", Me)
   job1.Download("http://myip.it:3015/special/GetAlunni?USERWEB='"&Main.USERWEB.Trim&"'&PWDUWEB='"&Main.PWDUWEB.Trim&"'&DBNAME='"&Main.DBNAME.Trim&"'")
....

Sub JobDone (Job As HttpJob)
   Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
   Log(Job.ErrorMessage)
   If Job.Success = True Then
       Dim res As String
       res = Job.GetString
       Log("Back from Job:" & Job.JobName )
       Log("Response from server: " & res)
       ' facciamo il parsing del json ricevuto
       Dim parser As JSONParser
       parser.Initialize(res)
  
       If Job.JobName="Job1" Then
           Log("job1 - alunni")
           Dim root As List = parser.NextArray
           'svuoto la tabella
           SQL1.ExecNonQuery("DELETE FROM STUDENTI")
           For Each colroot As Map In root
               Dim CodStude As String = colroot.Get("CODSTUDE")
               Dim DESSCUOL As String = colroot.Get("DESSCUOL")
               Dim CLASTUDE As String = colroot.Get("CLASTUDE")
               Dim SEZSTUDE As String = colroot.Get("SEZSTUDE")
               Dim VALBUONI As Double = colroot.Get("VALBUONI")
               Dim DTNASSTU As String = colroot.Get("DTNASSTU")
               Dim COGSTUDE As String = colroot.Get("COGSTUDE")
               Dim NOMSTUDE As String = colroot.Get("NOMSTUDE")
               Dim CODSCUOL As String = colroot.Get("CODSCUOL")
               Dim DESDIETA As String = colroot.Get("DIETA")
               ' inseriamo i dati nella tabella
               SQL1.ExecNonQuery2("INSERT INTO Studenti VALUES (?,?,?,?,?,?,?,?,?,?)", Array As Object (CodStude.Trim, COGSTUDE.Trim, NOMSTUDE.Trim, CODSCUOL.Trim, DESSCUOL.Trim, CLASTUDE.Trim, SEZSTUDE.Trim, DTNASSTU.Trim, VALBUONI, DESDIETA.Trim))
           Next
       End If
      
   Else
       Log("Error: " & Job.ErrorMessage)
       '   ToastMessageShow("Error: " & Job.ErrorMessage, True)
       Msgbox(Job.ErrorMessage,"Errore")
       ok_procedi = False
   End If
   Job.Release
   ProgressDialogHide
End Sub

ws response:
[{"CODSTUDE":"0000010028","COGSTUDE":"BARBETTA","NOMSTUDE":"GABRIELE","DTNASSTU":"","CODSCUOL":"_NESSUNA","DESSCUOL":"NON FREQUENTANTE","CLASTUDE":"","SEZSTUDE":"","VALBUONI":".00","DESDIETA":"NORMALE"},{"CODSTUDE":"0000013231","COGSTUDE":"BARBETTA","NOMSTUDE":"ALESSANDRO","DTNASSTU":"","CODSCUOL":"GARIB. E","DESSCUOL":"GARIBALDI ELEMENTARE","CLASTUDE":"3","SEZSTUDE":"B","VALBUONI":"-35.00","DESDIETA":"NORMALE"}]

I get the following error:
B4X:
JobName = Job1, Success = true
Back from Job:Job1
Response from server: {}
job1 - alunni
Error occurred on line: 204 (Studenti)
java.lang.RuntimeException: JSON Array expected.
   at anywheresoftware.b4a.objects.collections.JSONParser.NextArray(JSONParser.java:62)
   at b4a.example.studenti._jobdone(studenti.java:672)
   at java.lang.reflect.Method.invoke(Native Method)
   at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:733)
   at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:355)
   at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
   at java.lang.reflect.Method.invoke(Native Method)
   at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
   at anywheresoftware.b4a.BA$2.run(BA.java:365)
   at android.os.Handler.handleCallback(Handler.java:808)
   at android.os.Handler.dispatchMessage(Handler.java:101)
   at android.os.Looper.loop(Looper.java:166)
   at android.app.ActivityThread.main(ActivityThread.java:7425)
   at java.lang.reflect.Method.invoke(Native Method)
   at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)

the Json seems empty, why?

regards,
Ciro
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Something like

B4X:
Dim ws As String
   ws = "http://comune.refezionescolastica.it:3015/special/GetAlunni"
   Dim job1 As HttpJob
   job1.Initialize("Job1", Me)
   job1.Download2(ws,"USERWEB",Main.USERWEB.Trim,"PWDUWEB",Main.PWDUWEB.Trim,"DBNAME",Main.DBNAME.Trim)

Sorry, was a bit wrong...

This code works.
B4X:
    Dim ws As String
    ws = "http://comune.refezionescolastica.it:3015/special/GetAlunni"
    Dim job1 As HttpJob
    job1.Initialize("Job1", Me)
    job1.Download2(ws, Array As String("USERWEB","'14184'","PWDUWEB","'WEBBEBIE'","DBNAME","'FS_SCHOOL'"))
    Wait For (job1) JobDone(j As HttpJob)
    If j.Success Then
        Log(j.GetString)
    Else
        Log(j.ErrorMessage)
    End If
    j.Release
But again i am sure the ws behaviour is wrong as the Values MUST BE enclosed by ' otherwise the ws does return an empty Result. {}
 
Upvote 0

cirollo

Active Member
Licensed User
Longtime User
But again i am sure the ws behaviour is wrong as the Values MUST BE enclosed by ' otherwise the ws does return an empty Result. {}

so you suggest to remove the ' in the parameters:

job1.Download2(ws, Array As String("USERWEB","14184","PWDUWEB","WEBBEBIE","DBNAME","FS_SCHOOL"))

?? I can try to modify the ws and test it if this could solve the issue....
 
Upvote 0

OliverA

Expert
Licensed User
putting the string in a browser returns me the JSON filled with records:
Except you never give us the string you put in your browser. You only give us a B4A representation of that string, which is not the same thing. So, you need to give us an actual string that works with your browser.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Except you never give us the string you put in your browser.
He gave this url
http://comune.refezionescolastica.i...='14184'&PWDUWEB='WEBBEBIE'&DBNAME='FS_SCHOOL
But the server is not reachable as of now.

As you can see the "Values" are enclosed in %27 (')

http://comune.refezionescolastica.i...ERWEB=14184&PWDUWEB=WEBBEBIE&DBNAME=FS_SCHOOL
This url should be OK but the WS is returning nothing. The problem is in the ws as it requires ' to be in the values. This is not the correct behaviour.
The WS should not expect the values are enclosed in '

I´m still thinking the WS does not work as one would expect. I would NEVER expect the values must be enclosed by ' in a WS Call.
 
Upvote 0

OliverA

Expert
Licensed User
I would NEVER expect the values must be enclosed by ' in a WS Call
The reason for the single quotes is that he is passing on the parameter string (the whole string) to a where clause in an SQL statement. Doing some google-fu, I found this: https://forum.xojo.com/50711-ws-doesn-t-return-json/0. Looking at that code, I see a huge difference when it comes to processing the parameters for his GetUser and his GetAlunni.
1) GetAlluni is mispelled in his code, but think that was brought up in the post.
B4X:
case "GetAunni"
2) The processing of parameters for GetUser and GetAlunni are totally different. I think that is where his problem is. He creates a SQL string for GetUser, but not for GetAlunni
GetUser:
B4X:
case "GetUser"
' isoliamo i parametri
  parametri = NthField(Request.QueryString, "&", 1)+" and "+NthField(Request.QueryString, "&", 2)
  parametri = ReplaceAll (parametri,"%27","'")
 
  output = GetUser // Assign the processed data to the output variable, if the received method is 'GetAllAlbums'
  Request.Print( output.ToString ) // And send it back to the client that made the request, converting the JSON to a String in first place
GetAlunni:
B4X:
case "GetAunni"
  output = GetAlunni // Assign the processed data to the output variable, if the received method is 'GetAllAlbums'
  Request.Print( output.ToString ) // And send it back to the client that made the request, converting the JSON to a String in first place
He has 0 processing for the "parametri" variable in GetAlunni. I would have expected something like this:
B4X:
case "GetAlunni" 'Fixed spelling
' isoliamo i parametri
  'Below was missing. He is using 3 parameters, so I expanded the GetUser version to handle 3 parameters. I cannot guarantee that this 
  'works since I don't use whatever is being used here.
  parametri = NthField(Request.QueryString, "&", 1)+" and "+NthField(Request.QueryString, "&", 2)+" and "+NthField(Request.QueryString, "&", 3)
  parametri = ReplaceAll (parametri,"%27","'")
 
  output = GetUser // Assign the processed data to the output variable, if the received method is 'GetAllAlbums'
  Request.Print( output.ToString ) // And send it back to the client that made the request, converting the JSON to a String in first place

Even then, GetAlunni does not use the parametri variable as posted in the linked post. GetUser does and it looks something like this:
B4X:
Dim stringa_sql as string
stringa_sql="select USERWEB,PWDUWEB,DBNAME from Credenziali where "+parametri
As one can see, the parameters are used as the parameters for the WHERE clause of the SQL statement. The single quotes are for escaping and to let the SQL processor know that they are string literals.
I'm sure that the issue does not lie with B4A, but with the backend/webserver code that B4A is trying to communicate with.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
The reason for the single quotes is that he is passing on the parameter string (the whole string) to a where clause in an SQL statement.
I agree. But i still think it is the wrong behaviour a WS should have.
The WS should get the value as is, for numbers check if the numbers is ok.
The ' should be used in the SQL-Stement for sure. But not using the value without doing any SQL-Injection-Prevention.
 
Upvote 0

cirollo

Active Member
Licensed User
Longtime User
The reason for the single quotes is that he is passing on the parameter string (the whole string) to a where clause in an SQL statement. Doing some google-fu, I found this: https://forum.xojo.com/50711-ws-doesn-t-return-json/0. Looking at that code, I see a huge difference when it comes to processing the parameters for his GetUser and his GetAlunni.
1) GetAlluni is mispelled in his code, but think that was brought up in the post.
B4X:
case "GetAunni"
2) The processing of parameters for GetUser and GetAlunni are totally different. I think that is where his problem is. He creates a SQL string for GetUser, but not for GetAlunni
GetUser:
B4X:
case "GetUser"
' isoliamo i parametri
  parametri = NthField(Request.QueryString, "&", 1)+" and "+NthField(Request.QueryString, "&", 2)
  parametri = ReplaceAll (parametri,"%27","'")
 
  output = GetUser // Assign the processed data to the output variable, if the received method is 'GetAllAlbums'
  Request.Print( output.ToString ) // And send it back to the client that made the request, converting the JSON to a String in first place
GetAlunni:
B4X:
case "GetAunni"
  output = GetAlunni // Assign the processed data to the output variable, if the received method is 'GetAllAlbums'
  Request.Print( output.ToString ) // And send it back to the client that made the request, converting the JSON to a String in first place
He has 0 processing for the "parametri" variable in GetAlunni. I would have expected something like this:
B4X:
case "GetAlunni" 'Fixed spelling
' isoliamo i parametri
  'Below was missing. He is using 3 parameters, so I expanded the GetUser version to handle 3 parameters. I cannot guarantee that this
  'works since I don't use whatever is being used here.
  parametri = NthField(Request.QueryString, "&", 1)+" and "+NthField(Request.QueryString, "&", 2)+" and "+NthField(Request.QueryString, "&", 3)
  parametri = ReplaceAll (parametri,"%27","'")
 
  output = GetUser // Assign the processed data to the output variable, if the received method is 'GetAllAlbums'
  Request.Print( output.ToString ) // And send it back to the client that made the request, converting the JSON to a String in first place

Even then, GetAlunni does not use the parametri variable as posted in the linked post. GetUser does and it looks something like this:
B4X:
Dim stringa_sql as string
stringa_sql="select USERWEB,PWDUWEB,DBNAME from Credenziali where "+parametri
As one can see, the parameters are used as the parameters for the WHERE clause of the SQL statement. The single quotes are for escaping and to let the SQL processor know that they are string literals.
I'm sure that the issue does not lie with B4A, but with the backend/webserver code that B4A is trying to communicate with.


Yess! the ws is made with xojo, that was my topic, but the issue with "GetAunni" was fixed days ago, and was also fixed the parameters string (infact in browser works!).

This afternoon I'll try to remove the ' from the parameters and see if it solves the problem.

by the way, the ' are also present in the GetUser WS and B4A returns the expected values without any problem.....strange.....
 
Upvote 0

OliverA

Expert
Licensed User
Yess! the ws is made with xojo, that was my topic, but the issue with "GetAunni" was fixed days ago, and was also fixed the parameters string (infact in browser works!).

This afternoon I'll try to remove the ' from the parameters and see if it solves the problem.

by the way, the ' are also present in the GetUser WS and B4A returns the expected values without any problem.....strange.....
So what is the fixed code? There must be some difference, else the same code on the B4A side would not result in a different outcome. Removing the single quotes from the backend is not the solution right now, since the goal here is to see why one works and the other does not. I have an idea, but I would have to see your fixed code first.
 
Upvote 0

cirollo

Active Member
Licensed User
Longtime User
but I would have to see your fixed code first.

do you mean xojo code, right? here it is:

if you know xojo, this is handlespecialurl, where, after the ws calling, I do what I need:

B4X:
dim data as string = Request.Entity.DefineEncoding(encodings.UTF8) // We have to apply the right encoding to the received data
dim input as JSONItem = new JSONItem( data ) // Creating a new JSON object from it
dim output as JSONItem

parametri = Request.QueryString

Select Case Request.Path // What is the method received as part of the request? (URL)
 
case "GetUser"
  ' isoliamo i parametri
  parametri = NthField(Request.QueryString, "&", 1)+" and "+NthField(Request.QueryString, "&", 2)
  parametri = ReplaceAll (parametri,"%27","'")
 
  output = GetUser // Assign the processed data to the output variable, if the received method is 'GetAllAlbums'
  Request.Print( output.ToString ) // And send it back to the client that made the request, converting the JSON to a String in first place
 
case "GetAlunni"
  ' isoliamo i parametri
  parametri = NthField(Request.QueryString, "&", 1)+" and "+NthField(Request.QueryString, "&", 2)
  parametri = ReplaceAll (parametri,"%27","'")
 
  dbname = NthField(Request.QueryString, "&", 3)
  dbname = NthField(dbname, "%27", 2)
 
  output = GetAlunni // Assign the processed data to the output variable, if the received method is 'GetAllAlbums'
  Request.Print( output.ToString ) // And send it back to the client that made the request, converting the JSON to a String in first place
 
end select

Return true

this is the GetAlunni ws:

B4X:
Dim db As New MSSQLServerDatabase

db.Host =host // or just the IP if using the default instance
db.DatabaseName = dbname
db.UserName = user  // or "Domain\UserID for trusted domain accounts
db.Password = pass


If db.Connect Then
 
  Dim stringa_sql as string
  stringa_sql= "select ANA_STUD.CODSTUDE,ANA_STUD.COGSTUDE,ANA_STUD.NOMSTUDE,ANA_STUD.DTNASSTU,DTA_STUDE.CODSCUOL,ANA_SCUO.DESSCUOL,DTA_STUDE.CLASTUDE,DTA_STUDE.SEZSTUDE, "_
  +"DTA_STUDE.VALBUONI,ANA_DIET.DESDIETA FROM ANA_STUD LEFT OUTER JOIN DTA_STUDE ON ANA_STUD.CODSTUDE=DTA_STUDE.CODSTUDE "_
  +"LEFT OUTER JOIN ANA_DIET ON DTA_STUDE.CODDIETA=ANA_DIET.CODDIETA "_
  +"LEFT OUTER JOIN ANA_SCUO ON DTA_STUDE.CODSCUOL=ANA_SCUO.CODSCUOL WHERE "+parametri+" AND DTA_STUDE.CODANNSC='18/19'"
 
  Dim ps As MSSQLServerPreparedStatement
  ps = db.Prepare(stringa_sql)
 
  Dim rs As RecordSet = ps.SQLSelect
 
  dim item as new JSONItem
  dim a as jsonitem
  dim numrec as Integer
  numrec=0
  if rs <> Nil Then
    While Not rs.EOF
      numrec=numrec+1
      a = new JSONItem // creating a new dictionary for each record, and that we will convert in a node
      a.Value("CODSTUDE") = rs.IdxField(1).StringValue.TRIM
      a.Value("COGSTUDE") = rs.IdxField(2).StringValue.TRIM
      a.Value("NOMSTUDE") = rs.IdxField(3).StringValue.TRIM
      a.Value("DTNASSTU") = rs.IdxField(4).StringValue.TRIM
      a.Value("CODSCUOL") = rs.IdxField(5).StringValue.TRIM
      a.Value("DESSCUOL") = rs.IdxField(6).StringValue.TRIM
      a.Value("CLASTUDE") = rs.IdxField(7).StringValue.TRIM
      a.Value("SEZSTUDE") = rs.IdxField(8).StringValue.TRIM
      a.Value("VALBUONI") = rs.IdxField(9).StringValue.TRIM
      a.Value("DESDIETA") = rs.IdxField(10).StringValue.TRIM
      item.append(a)
      rs.MoveNext
    Wend
    rs.Close
  End If
  db.Close
 
  Return item // And return it to the caller
Else
  MsgBox("Connection error:" + db.ErrorMessage)
End If

after // are comments in xojo

if you check:

http://comune.refezionescolastica.i...='14184'&PWDUWEB='WEBBEBIE'&DBNAME='FS_SCHOOL

you can see that works, yesterday I stopped the ws. Now is again up
 
Last edited:
Upvote 0

OliverA

Expert
Licensed User
do you mean xojo code, right
Yes. And I see something different. Should
B4X:
dbname = NthField(dbname, "%27", 2)
not be
B4X:
dbname = ReplaceAll (dbname,"%27","'")
?
When you access the site via your browser, you use '. But when you use B4A, it converts the ' to %27, in which case your xojo code will fail because it does not correctly convert %27 to '.
if you know xojo
I don't
 
Upvote 0

cirollo

Active Member
Licensed User
Longtime User
No, because where is used dbname the ' are not necessary, here:

B4X:
Dim db As New MSSQLServerDatabase

db.Host =host // or just the IP if using the default instance
db.DatabaseName = dbname    <<<<<<< HERE I DON'T NEED THE '
db.UserName = user  // or "Domain\UserID for trusted domain accounts
db.Password = pass

and also, after this
B4X:
dbname = NthField(Request.QueryString, "&", 3)
I obtain the dbname isolated from the other params:
this is what I see in debug >>>> DBNAME=%27FS_SCHOOL%27

and also, after this
B4X:
dbname = NthField(dbname, "%27", 2)
I remove the ' that I don't need:
this is what I see in debug >>>> FS_SCHOOL

this is what nthfield does:
NthField
From Xojo Documentation
Method


Returns a field from a row of data. The first field is numbered 1. If you need to parse binary data, use NthFieldB instead.

Syntax
result=NthField(source, separator, fieldNumber)
OR
result=stringVariable.NthField(separator, fieldNumber) Introduced 5.0

Part Type Description
result String The field value desired.
source String The string that contains the desired field, with the field separated by the Separator string.
separator String The string that separates columns of data.
fieldNumber Integer The column number of the desired field. The first field is numbered 1.
stringVariable String Any variable of type String.
Notes
The NthField function returns the field value from the source that precedes the fieldNumber occurrence of the separator in the source.

The separator may be a string of any length.

If fieldNumber is out of bounds, an empty string is returned. NthField is not case-sensitive.


Using NthField in a loop to extract fields from a string is inefficient. You should use Split for this purpose.
Examples
This example returns "Smith"

Dim field As String
field = NthField("Dan*Smith*11/22/69*5125554323*Male", "*", 2)
Using the second syntax:

Dim s, field As String
s = "Dan*Smith*11/22/69*5125554323*Male"
field = s.NthField("*", 2)
MsgBox(field)
This example demonstrates the use of a multiple character separator.

Dim days As String = "Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday"
Dim wed As String = NthField(days, ",", 3) // sets wed to "Wednesday"

if B4A converts the ' to %27 it should work

I guess why in browser is still working using %27 or ' in the url.....I think xojo code is correct.
 
Last edited:
Upvote 0

OliverA

Expert
Licensed User
Something must have changed or there is a big difference in B4J and B4A because this works:
B4X:
'Non-UI application (console / server application)
#Region Project Attributes
   #CommandLineArgs:
   #MergeLibraries: True
#End Region

Sub Process_Globals
   Dim USERWEB As String
   Dim PWDUWEB As String
   Dim DBNAME As String
End Sub

Sub AppStart (Args() As String)
   USERWEB = "14184"
   PWDUWEB = "WEBBEBIE"
   DBNAME = "FS_SCHOOL"
   testsub
   StartMessageLoop
End Sub
Sub testsub
   Dim job1 As HttpJob
   job1.Initialize("Job1", Me)
   job1.Download("http://comune.refezionescolastica.it:3015/special/GetAlunni?USERWEB='"&USERWEB.Trim&"'&PWDUWEB='"&PWDUWEB.Trim&"'&DBNAME='"&DBNAME.Trim&"'")
   Wait For (job1) JobDone(j As HttpJob)
   If j.Success Then
       Log(j.GetString)
   Else
       Log(j.ErrorMessage)
   End If
   j.Release
   StopMessageLoop
   'http://comune.refezionescolastica.it:3015/special/GetAlunni?USERWEB=%2714184%27&PWDUWEB=%27WEBBEBIE%27&DBNAME=%27FS_SCHOOL
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
   Return True
End Sub
Result:
[{"CODSTUDE":"0000014184","COGSTUDE":"MONACELLI","NOMSTUDE":"PAOLO","DTNASSTU":"2012-04-30 00:00:00","CODSCUOL":"CORRIDONI","DESSCUOL":"UMBERTO I (CORRIDONI)","CLASTUDE":"1","SEZSTUDE":"A","VALBUONI":"-5.00","DESDIETA":"NORMALE"}]
The only difference in this Download from your Download in post#1 is that I'm doing this in Main and don't need the Main. prefix for my variables.
 
Upvote 0

OliverA

Expert
Licensed User
Update: Same above works in B4A
B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Dim USERWEB As String
   Dim PWDUWEB As String
   Dim DBNAME As String
End Sub

Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   'Activity.LoadLayout("Layout1")
   USERWEB = "14184"
   PWDUWEB = "WEBBEBIE"
   DBNAME = "FS_SCHOOL"
   testsub
End Sub

Sub testsub
   Dim job1 As HttpJob
   job1.Initialize("Job1", Me)
   job1.Download("http://comune.refezionescolastica.it:3015/special/GetAlunni?USERWEB='"&USERWEB.Trim&"'&PWDUWEB='"&PWDUWEB.Trim&"'&DBNAME='"&DBNAME.Trim&"'")
   Wait For (job1) JobDone(j As HttpJob)
   If j.Success Then
       Log(j.GetString)
   Else
       Log(j.ErrorMessage)
   End If
   j.Release
   'http://comune.refezionescolastica.it:3015/special/GetAlunni?USERWEB=%2714184%27&PWDUWEB=%27WEBBEBIE%27&DBNAME=%27FS_SCHOOL
End Sub
 
Upvote 0
Top