Dim j As HttpJob
j.Initialize("", Me)
j.GetRequest.SetContentType("text/xml")
j.PostString(Main.ServerURL,PostString)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
xml_parser.Initialize
xml_parser.Parse(j.GetInputStream, "Parser")
Else
xui.MsgboxAsync("Server Connection Error: " & j.ErrorMessage , "Error")
End If
j.Release
This code works perfectly for me in B4i but not in B4A. I get the below runtime error message:
java.lang.RuntimeException: Only Post / Put requests support this method.
The error points to this line: j.GetRequest.SetContentType("text/xml")
If I use the Http andHttpUtils2 libraries I get this error message, which crashes the app on runtime:
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/client/methods/HttpPost; - I am trying to connect to an SSL server but I have added HU2_ACCEPTALL to Build Configurations Conditional Symbols.
If I use the OkHttpUtils2 libraries I get this error message on larger downloads from the server, which does not crash the app:
Dim j As HttpJob
j.Initialize("", Me)
j.PostString(Main.ServerURL,PostString)
j.GetRequest.SetContentType("text/xml")
j.GetRequest.SetHeader("Accept-Encoding","identity")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
'parse your data here
Else
'error message here
End If
j.Release
This is less than a rare problem with OkHttpUtils2 - if you write your own server-side APIs as I do then it is not too hard to track down but if you rely on someone else for the server APIs this can be a killer problem.