iOS Question HttpPostMultipart works in B4A doesn't post in B4i


Active Member
Licensed User
Longtime User
I have code that posts data to an SSL page in PHP on an Apache server. The code is the same on both platforms and works from Android but doesn''t post from the iPhone. The server responds with a message that not all the required data items were posted. This clearly indicates that the server was contacted and can respond but that the post itself didn't succeed (I wrote the server code so know this is true). You'll note that both posted maps contain the same 14 data items.

The code is a service in B4A and a class in B4i. The iHttpUtils2 version is 3.02. The B4i version is 8.30 and I'm using the hosted builder.

What could be the problem?

Here's the B4X code:

Logged Post:
Log("Sending to Server: " & CommMap)
Wait For (HttpPostMultipart(CommURL, CommMap)) Complete (Result As String)
Log("Raw server response: " & Result )

In B4i, here's the log:

Sending to Server: NSMapTable {
[2] scallapp_version -> 0.04
[5] phone -> 4015551212
[6] vessel_2 -> comet
[7] last_name -> smith
[10] vessel_1 -> Strega
[15] email -> [email protected]
[17] vessel_3 -> nimble
[18] first_name -> john
[21] verified -> 0
[24] device_type -> iPhone
[26] id -> 0
[30] os_version -> iOS
[31] device_id -> 1234567890
Raw server response: Error: (14) The post does not contain all fields

In B4A, here's the log:

*** Service (comm) Create ***
** Service (comm) Start **
Sending to Server: (MyMap) {phone=4015551212, passcode=XXXXXXXXXXXXXXXXXXXX, last_name=smith, vessel_3=nimble, email=[email protected], vessel_2=comet, verified=0, first_name=john, vessel_1=strega, id=0, device_type=samsung - SM-A516U1, os_version=Android SDK: 33 (13), scallapp_version=0.04, device_id=1d1ed30c74b37c50}
*** Receiver (httputils2service) Receive (first time) ***
Raw server response: 11-1-U-QUaSAWexVbrZZYJjBNQl

Thanks for any assistance.


Licensed User
Longtime User
It is difficult to guess without seeing the code. Multipart post usually use for uploading image or files to server. As far as I know, there is little different in B4i version. If you only sending String data, why not just use PostString?

Upvote 0


Active Member
Licensed User
Longtime User
Thank you for your replies. Both make sense and are valuable. I have been searching for full documentation of the OKHttpUtils2 library and have been unable to find a good learning resource. I've been working from forum problems/examples. Where exactly can I find comprehensive description of the library and it's capabilities?
Upvote 0


Active Member
Licensed User
Longtime User
I realize I didn't include the Sub HttpPostMultipart. Here it is:

Sub HttpPostMultipart:
Private Sub HttpPostMultipart(Link As String, Parameters As Map) As ResumableSub
    Dim Result As String
    Dim j As HttpJob
        j.Initialize("", Me)
        j.PostMultipart(Link, Parameters, Null)
        j.GetRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded")
        Wait For (j) JobDone(j As HttpJob)
        If j.Success Then
            Result = j.GetString 'the request response type?
            Log("usuccessful contact")
            Result = "Can't contact server."
        End If
        Log("Error in multipart post: " & LastException)
    End Try
    Return Result
End Sub
Upvote 0


Active Member
Licensed User
Longtime User
I appreciate that. However, there's no error. The httpjob succeeds. Result is the response returned from the server. On the server PHP sees a post type request but there are no values posted. The server responds with that message. Again, only from B4i. B4A works.
Upvote 0