Android Question Unable to read httpjob response headers


Active Member
Licensed User
My Android App has OkHttp and OkHttpUtils2 libraries. Now I use B4A v.8.80.
In this app, about two years ago I have implemented a HTTP communication with a remote server. May be that at that time I was using HttpUtils library.
The communication was working very good and was working in the iOS version of the same app too (with iHttp library).
This communication has been not used till today, but now I need to use it.
The JobDone event is the following (it'is the same in Android and in iOS):
Sub JobDone(j As HttpJob)
    If j.Success Then
        If    j.JobName = "signup" Then    'TEST 15/06/2017
            Log("j.GetString = " & j.GetString)
            Log("j.Tag = " & j.Tag)
            If j.GetString.Contains("status") And j.GetString.Contains("ok") Then
                Dim Headers As Map = j.tag           
                If Headers.Size > 0 Then
                    If Headers.Get(TokenHeaderName) <> "" Then   
                        LastToken = Headers.Get(TokenHeaderName)
The problem is that the Android app crashes when reach this line:
 Dim Headers As Map = j.tag

But the iOS app still works fine like two years ago

If in the Android app I put a breakpoint before that line and I check J.Tag it appears as empty.

The Android Log is this:
j.GetString = {"status":"ok"}
j.Tag = java.lang.Object@92d7b8a
Error occurred on line: 366 (Service2)
java.lang.ClassCastException: java.lang.Object cannot be cast to anywheresoftware.b4a.objects.collections.Map$MyMap
at anywheresoftware.b4a.objects.collections.Map.getSize(
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(
at anywheresoftware.b4a.BA$
at android.os.Handler.handleCallback(
at android.os.Handler.dispatchMessage(
at android.os.Looper.loop(
at java.lang.reflect.Method.invoke(Native Method)
The iOS Log is this:
j.GetString = {"status":"ok"}
j.Tag = (read only map) {
Authorization = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjYwMzMsImlzcyI6Imh0dHBzOi8vbG9nLnJpdG1vLmNsb3VkL2FwaS9hdXRoL3NpZ251cCIsImlhdCI6MTU1MjY2MTQ0NiwiZXhwIjoxNTUyNjY1MDQ2LCJuYmYiOjE1NTI2NjE0NDYsImp0aSI6Im13b01OVVU5OGtDM3d1NGMifQ.zZ8sYcrOnCM1yqqZ8CtIoUWeSU6fWUXfQVNFaXXCYEw";
"Cache-Control" = "private, must-revalidate";
Connection = "keep-alive";
"Content-Type" = "application/json";
Date = "Fri, 15 Mar 2019 14:50:46 GMT";
Etag = "\"55a490e280d48996e564d00492437eb17faadd28\"";
Server = "nginx/1.10.3 (Ubuntu)";
"Transfer-Encoding" = Identity;
"X-RateLimit-Limit" = 1;
"X-RateLimit-Remaining" = 0;
Please someone can help me to fix this problem?
Thanks a Lot to everybody.


Licensed User
Please someone can help me to fix this problem?
Asuming you are using the newest b4a and okhttputils libraries

Sub JobDone (Job As HttpJob)
    Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
    If Job.Success = True Then
        Dim response As OkHttpResponse = Job.Response
        Dim respHeaders As Map = response.GetHeaders