HTTPUtils2 .NET Framework problem

fbritop

Active Member
Licensed User
Longtime User
Erel,
I'm using httputils2 to retrieve a remote json string.

Wierd thing is that when I retrieve it from a classic ASP page, it goes fine, but when I try to pull it from a VB.Net page, it responds an empty string. Do you know what this could be?

Classic ASP URL: http://autorizalo.inoba.com/ext/bac...imE8pjWgOD0k6&token=123456&mobile=56991296532
.NET URL: http://autorizalo.inoba.com/ext/def...imE8pjWgOD0k6&token=123456&mobile=56991296532

The code for the request is:

B4X:
   Dim url As String=Main.SystemDomainEndPoint & "?FLAG=SEARCH.SHOP&lat=" & x.ReadMap("lat") & "&lon=" & x.ReadMap("lon")
   Dim jobSHOP As HttpJob
   'jobSHOP.GetRequest.SetHeader("user-agent","webkit")
    jobSHOP.Initialize("jobSHOP", Me)
   jobSHOP.PostString(url, "")   
   jobSHOP.GetRequest.SetHeader("user-agent","webkit")
   jobSHOP.GetRequest.SetHeader("host","autorizalo.inoba.com")

The LOG Shows:
B4X:
actpager_listshopsget (B4A line: 881)
Dim Map1 As Map = JSONP.NextObject
org.json.JSONException: End of input at character 0 of 
   at org.json.JSONTokener.syntaxError(JSONTokener.java:450)
   at org.json.JSONTokener.nextValue(JSONTokener.java:97)
   at anywheresoftware.b4a.objects.collections.JSONParser.NextObject(JSONParser.java:45)
   at com.autorizalo.android.actpager._listshopsget(actpager.java:1892)
   at com.autorizalo.android.actpager._jobdone(actpager.java:1559)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
   at anywheresoftware.b4a.keywords.Common$4.run(Common.java:930)
   at android.os.Handler.handleCallback(Handler.java:615)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:137)
   at android.app.ActivityThread.main(ActivityThread.java:4921)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
   at dalvik.system.NativeStart.main(Native Method)
org.json.JSONException: End of input at character 0 of

Which is why the output comes empty


Thanks
Felipe Brito
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
I tried this code and it works correctly:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Dim j As HttpJob
   j.Initialize("j", Me)
   j.Download("http://autorizalo.inoba.com/ext/default.aspx?FLAG=TOKEN.SEND&hashEntity=1029InimE8pjWgOD0k6&token=123456&mobile=56991296532")
End Sub
Sub JobDone(j As HttpJob)
   Log(j.Success)
   If j.Success Then
      Log(j.GetString)
      Dim parser As JSONParser
      parser.Initialize(j.GetString)
      Log(parser.NextObject)
   Else
      Log(j.ErrorMessage)
   End If
   j.Release
End Sub

Make sure that you check the success flag.
 
Upvote 0
Top