Android Question PostString/PostBytes Not receiving posted data back

dannyjon

Member
Licensed User
Have used this method many times before without problems but now I can't get the ASP page to return the data passed from B4A.

B4a code:
Dim nettest As HttpJob
nettest.Initialize("nettest", Me)
Dim str As String = "121321231"
nettest.Initialize("nettest", Me)
nettest.PostBytes( "http://xxx.xxx/netreply.aspx?x=",str.GetBytes("UTF8"))

ASP Code should return var str..but only returns 'QS Rec:'
Dim stringReceived As String = String.Empty
Dim Result As String = String.Empty
Result = Server.HtmlEncode(Request.QueryString(0).ToString)
Response.Write("QS rec: " + Result.ToString)

Thanks all.
 

DonManfred

Expert
Licensed User
what result (or error) do you get in sub jobdone?

B4X:
Sub JobDone (Job As HttpJob)
  Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
  If Job.Success = True Then
      Select Job.JobName
        Case "nettest"
          Log(Job.GetString)
      Case ".."
          Log(Job.GetString)
      End Select
  Else
      Log("HttpJob-Error: " & Job.ErrorMessage)
    ToastMessageShow("Error: " & Job.ErrorMessage, True)
  End If
  Job.Release
End Sub
 

dannyjon

Member
Licensed User
Dim t_result As String = Job.getstring
lvSendProgress.AddTwoLinesAndBitmap("t_result: " & t_result,DateTime.Time(now),LoadBitmap(File.DirAssets,"check-icon.png"))

Have just checked similar code for another app I have and that too is also not showing the string response from the as server, only the hard coded text which precedes it.

When testing the ASP code in Chrome it DOES return the query-string passed via html encoding so it, just not on B4A.
 
Last edited:

DonManfred

Expert
Licensed User
When you get the result in a browser then you probaly call the wrong url...
How are you able to send a POST-BYTES in a browser??
job.postbytes is probably the wrong one to use... looking at your url in post #1 i would suggest using job.download (GET Request)

Can you post your project incl webservice-url?
 
Last edited:

dannyjon

Member
Licensed User
Thanks for your reply. I was using PostString and this worked ok. Job.download will not be suitable for this because there is no file being downloaded. The PostBytes also works in the browser. Also the post is not going to a Web Service but to an .aspx page.
 

DonManfred

Expert
Licensed User
Job.download will not be suitable for this because there is no file being downloaded
BUT you want the result output from your webservice or not? So you do a "Download" for this informations.
Dont treat "download" as a file which will be downloaded to somewhere... Job.Download is a get-Request send to a host and the result you can get in JobDone. You CAN save the data if you want... But you dont need to if you dont want
 

dannyjon

Member
Licensed User
Ok thanks for your help. Have resolved it by recycling some old code - no obvious reason why the above failed but I have found a work around. Thanks again.
 
Top