Android Question ResponseError. Reason: Internal Server Error, Response: Using OkHttpUtils2 Library

Walter Scafati

Active Member
Licensed User
Longtime User
Hi, I using the OkHttpUtils2 library per to communicate with my server via JSON message.
Sometimes I have the error "ResponseError. Reason: Internal Server Error, Response:" and I can'receive the data.

Like the post: https://www.b4x.com/android/forum/t...ad-of-a-file-fails-httputils2-succeeds.87041/
I removed the OkHttpUtils2 library and I added the two source code file of this (HttpJob.bas and HttpUtils2Service.bas) but I have the error:

B4A Versione: 7.80
Analisi del Codice. Error
Errore Analisi Programma.
Descrizione errore: Tipo sconosciuto: okhttprequest
Manca un riferimento ad una libreria?
Errore nella linea: 11 (HttpJob)
Private req As OkHttpRequest


The row 11 is:

B4X:
Private req As OkHttpRequest

Must add I some library?
 

Walter Scafati

Active Member
Licensed User
Longtime User
After the add of OkHttp I have this error:

B4A Versione: 7.80
Analisi del Codice. Error
Riferimento a un oggetto non impostato su un'istanza di oggetto.

From the other post:
You need to remove OkHttpUtils2 library and replace it with the two code modules. Make HttpUtils2Service.hc a public variable.

I don't understand this step, where I must to declare the HttpUtils2Service.hc? what Type of variable for the declaration?

Public HttpUtils2Service.hc as ?
 
Upvote 0

Walter Scafati

Active Member
Licensed User
Longtime User
No, I did not know that for the zip file must to use the "Export as zip" from b4a, I did use the winzip software. Sorry is the first time that I make the upload of one project.
Now I do it from b4a but is the same, my zip project is 587 KBytes, but the message teels me:

The following error occurred
The uploaded file is too large.
 
Upvote 0

Walter Scafati

Active Member
Licensed User
Longtime User
Now the error is disappeared, but after the compilation and the installation on the device, the App exit at the moment of check new version via AppUpdating function.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Yes, because now the other applications that using the AppUpdating Library not working more.
This can be solved easily. Add a reference to OkHttpUtils2 library in these projects.

You can also compile your own version of OkHttpUtils2. Make sure to update it in the internal libraries folder.
 
Upvote 0

Walter Scafati

Active Member
Licensed User
Longtime User
Hi Erel, I choose this way:
You can also compile your own version of OkHttpUtils2. Make sure to update it in the internal libraries folder.

I compiled my OkHttpUtils2My using the two files (HttpJob.bas and HttpUtils2Service.bas) and I added in the main of library project this part of code for the cookie deleting

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

If HttpUtils2Service.hc.IsInitialized Then
       Dim jo As JavaObject = HttpUtils2Service.hc
       jo = jo.GetFieldJO("client").RunMethod("cookieJar", Null)
       Dim r As Reflector
       r.Target = jo
       Dim CookieManager As JavaObject = r.GetField("cookieHandler")
       CookieManager.RunMethodJO("getCookieStore", Null).RunMethod("removeAll", Null)
End If

but I have always the same error "ResponseError. Reason: Internal Server Error, Response:" on one of the queries.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…