Android Question Expectation Failed

Fabio Campanella

Member
Licensed User
Longtime User
Hi,
when I use the Httpjob with basic autentication and json data i receive the 417 Error to the server (Expectation Failed)

I find this solution but I don't know when I pass this in Jttpjob class

Can you help me?

B4X:
request.getParams().setBooleanParameter( "http.protocol.expect-continue", false )
 

Fabio Campanella

Member
Licensed User
Longtime User
No, I use Http and httputils2 because i don't able to write the following code with same behaviour:

B4X:
private Sub CallWS(callMode As Int, WSName As String, Firmed As Boolean, JSONData As String)
  
   LastCallType = callMode
  
   Dim j As HttpJob
   j.Initialize(WSName, Me)  
   Dim BC As ByteConverter
   Dim Data() As Byte = BC.StringToBytes(JSONData, "utf-8")
   If callMode = CALL_MODE_POST Then
     'j.PostString(EndPoint & WSName, JSONData)
     j.PostBytes(EndPoint & WSName, Data)    
   Else
     j.Download(EndPoint & WSName & JSONData)
   End If
  
   j.GetRequest.Timeout = 25000
   j.GetRequest.SetHeader("Content-Type", mContentType & ";charset=utf-8")
   'j.GetRequest.SetContentType(mContentType)
   'j.GetRequest.SetContentEncoding("UTF-8")
   If Firmed = True Then
     j.GetRequest.SetHeader("Authorization", "Bearer " & mFirm)    
     If callMode = CALL_MODE_POST Then
      
     End If
   End If
  
   ' Azzera le variabili impostate in precedenza
   If mVars.IsInitialized = True Then mVars.Clear
   mVars.Initialize
  
   If mList.IsInitialized = True Then mList.Clear
   mList.Initialize
  
  
  
End Sub

I'm not be able to set the header with okhttp
 
Upvote 0

Fabio Campanella

Member
Licensed User
Longtime User
When Compile HttpUtils2Sercivice I've received this error:

:(


src\it\digitalup\icommlab\myhttputils2service.java:247: error: cannot access ClientProtocolException
_hc.Initialize("hc");
^
class file for org.apache.http.client.ClientProtocolException not found
 
Upvote 0

Fabio Campanella

Member
Licensed User
Longtime User
VERY SORRY Erel!!!
The problem was in the server. The payload json contained a variable that he did not like

I was angry with the customer for the time that made me lose! Sorry!!! is ok now without a variable. in my code that send before, leave latitude and longitude vars.

Thank for your precious support!!!!
Regards!!
Fabio
 
Upvote 0
Top