iOS Question Problem in Using Rest API

akh655xp

Member
Licensed User
Longtime User
Hi,
I am newbie in B4I and need to use Rest API for Negotiate with Server,
I Use Postman to getting code for that and get this code snippets in java OK Http format :

''''''''''''''''''''''''''''''''''''''''''
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "PhoneNumber=xxxxxxxxxxx");
Request request = new Request.Builder()
.url("http://192.1.101.14:1588/api/accounts/Login")
.post(body)
.addHeader("content-type", "application/x-www-form-urlencoded")
.addHeader("cache-control", "no-cache")
.addHeader("postman-token", "83e1fa87-2e58-b63b-272b-5051ab8eb827")
.build();

Response response = client.newCall(request).execute();
'''''''''''''''''''''''''''''''''''''''''

Please Help me to use it in B4I?

Please excuse me for bad english.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Start with:
B4X:
Dim j As HttpJob
j.Initialize("", Me)
j.PostString("http://192.1.101.14:1588/api/accounts/Login", "PhoneNumber=xxxxxxxxxxx")
j.GetRequest.SetContentType("application/x-www-form-urlencoded")
j.GetRequest.SetHeader("postman-token", "83e1fa87-2e58-b63b-272b-5051ab8eb827")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
   Log(j.GetString)
End If
j.Release

Depends on: iHttpUtils2 and iHttp libraries.
 
Upvote 0
Top