Another first for me.... again, probably something fundamental or simple, but I can't see it.
I have created a WebApi server running on Windows and am attempting to call a web api method from the mobile. The request makes it to my server, and causes dispatch of the function, and the server responds with a valid return-value (string array), as is evidenced by my web server session logs. But on the mobile side I get a File Not Found Exception - open failed: EISDIR (Is a directory).
job.GetString() is line 192 of main, and the exception logged at the mobile is
Error occurred on line: 192 (Main)
java.io.FileNotFoundException: /: open failed: EISDIR (Is a directory)
at libcore.io.IoBridge.open(IoBridge.java:409)
at java.io.FileInputStream.<init>(FileInputStream.java:78)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:209)
at anywheresoftware.b4a.samples.httputils2.httpjob._getstring2(httpjob.java:155)
at anywheresoftware.b4a.samples.httputils2.httpjob._getstring(httpjob.java:144)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:302)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78)
at android.view.View.performClick(View.java:4633)
at android.view.View$PerformClick.run(View.java:19270)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5476)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
Caused by: libcore.io.ErrnoException: open failed: EISDIR (Is a directory)
at libcore.io.IoBridge.open(IoBridge.java:398)
... 26 more
Something must be working because my server sees the request, and responds in JSON just fine. I suspect it has nothing to do with the JSON bodies going back and forth for request and response, but probably more likely a misuse or abuse of HTTPJOB ??
I have created a WebApi server running on Windows and am attempting to call a web api method from the mobile. The request makes it to my server, and causes dispatch of the function, and the server responds with a valid return-value (string array), as is evidenced by my web server session logs. But on the mobile side I get a File Not Found Exception - open failed: EISDIR (Is a directory).
B4X:
Sub btnGetTrucks_Click
PLog("Starting btnGetTrucks_Click")
Try
Dim rmc As RemoteMethodCall
rmc.Initialize
rmc.Method = "GetKnownTrucks"
Dim prms As Map
prms.Initialize
rmc.Parameters.Add(prms)
rmc.ReturnType = "String()"
Dim job As HttpJob
job.Initialize("job",Me)
Dim link As String = WebApiBaseUrl
Dim text As String = rmc.ToJSON
PLog(" - Making request: link=" & link & ", text=" & text )
job.PostString(WebApiBaseUrl , text )
Dim rsp As String = job.GetString()
PLog(" - response is """ & rsp & """")
Catch
PLog(" - *EXCEPTION* " & LastException.Message)
End Try
job.GetString() is line 192 of main, and the exception logged at the mobile is
Error occurred on line: 192 (Main)
java.io.FileNotFoundException: /: open failed: EISDIR (Is a directory)
at libcore.io.IoBridge.open(IoBridge.java:409)
at java.io.FileInputStream.<init>(FileInputStream.java:78)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:209)
at anywheresoftware.b4a.samples.httputils2.httpjob._getstring2(httpjob.java:155)
at anywheresoftware.b4a.samples.httputils2.httpjob._getstring(httpjob.java:144)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:302)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78)
at android.view.View.performClick(View.java:4633)
at android.view.View$PerformClick.run(View.java:19270)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5476)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
Caused by: libcore.io.ErrnoException: open failed: EISDIR (Is a directory)
at libcore.io.IoBridge.open(IoBridge.java:398)
... 26 more
Something must be working because my server sees the request, and responds in JSON just fine. I suspect it has nothing to do with the JSON bodies going back and forth for request and response, but probably more likely a misuse or abuse of HTTPJOB ??