ws doesn't return json

Hi!,
I’ve made two webservices using handlespecialURL method.

the first, called GetUser, is working correctly:

Dim db As New MSSQLServerDatabase

db.Host =host // or just the IP if using the default instance
db.DatabaseName = dbnm
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 USERWEB,PWDUWEB,DBNAME from Credenziali where "+parametri
  
  Dim ps As MSSQLServerPreparedStatement
  ps = db.Prepare(stringa_sql)
  
  Dim rs As RecordSet = ps.SQLSelect
  dim item as new JSONItem
  dim numrec as Integer
  numrec=0
  if rs <> Nil Then
    While Not rs.EOF
      numrec=numrec+1
      dim d as new Dictionary 
      d.Value("USERWEB") = rs.IdxField(1).StringValue
      d.Value("PWDUWEB") = rs.IdxField(2).StringValue 
      d.Value("DBNAME") = rs.IdxField(3).StringValue 
      item.Insert(numrec,d)
      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

the secon doesn’t send a result, I get only a blank browser page:

Dim db As New MSSQLServerDatabase

db.Host =host // or just the IP if using the default instance
db.DatabaseName = "FS_School" 'dbnm
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 CODSTUDE,COGSTUDE,NOMSTUDE FROM ANA_STUD WHERE CODSTUDE='0000010028'"
  
  Dim ps As MSSQLServerPreparedStatement
  ps = db.Prepare(stringa_sql)
  
  Dim rs As RecordSet = ps.SQLSelect
  dim item as new JSONItem
  dim numrec as Integer
  numrec=0
  if rs <> Nil Then
    While Not rs.EOF
      numrec=numrec+1
      dim a as new Dictionary
      a.Value("CODSTUDE") = rs.IdxField(1).StringValue 
      a.Value("COGSTUDE") = rs.IdxField(2).StringValue 
      a.Value("NOMSTUDE") = rs.IdxField(3).StringValue
      item.Insert(numrec,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

these are the calling instructions in handlespecialurl

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

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 "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
  
end select

Return true

if i put the not working js under a button action event, I get the result:

[{“CODSTUDE”:“0000010028”,“COGSTUDE”:“BARBETTA”,“NOMSTUDE”:“CICCIO”}]

I tried also to create the Json using this other method:

  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 // assingning the record ID to the name 'ArtistId' of the JSONItem
  a.Value("COGSTUDE") = rs.IdxField(2).StringValue.TRIM // and the Title value to the 'Title' field of the JSONItem
  a.Value("NOMSTUDE") = rs.IdxField(3).StringValue.TRIM // and the Title value to the 'Title' field of the JSONItem
  item.append(a)

Is that a typo?

well, is not a typo.

Consider that this:

case “GetUser”

works! the GetUser web service returns the json correctly

I started from this: https://blog.xojo.com/2018/09/26/web-services-xojo-web-at-your-service/

Your Request.Path could be either “GetUser” or “GetAunni” (or should be “GetAlunni”)?

yes it should be GetALunni

thank you!