Android Question API request (GET) with token

h4an

Member
Licensed User
Longtime User
I'm sorry I have to write this thread. I have looked at several API threads to figure out how to make this API GET work in B4A. Copied from Postman:

OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("http://airsports.no/api/v1/contests/")
.method("GET", body)
.addHeader("Authorization", "Bearer .....................")
.build();
Response response = client.newCall(request).execute();

Some code exampel in B4A please.
 

aeric

Expert
Licensed User
Longtime User
B4X:
Dim job As HttpJob
job.Initialize("", Me)
job.Download("http://airsports.no/api/v1/contests/")
job.GetRequest.SetHeader("Authorization", "Bearer .....................")
Wait For (job) JobDone(job As HttpJob)
If job.Success Then
   Log(job.GetString)
  
End If
job.Release
 
Upvote 2

h4an

Member
Licensed User
Longtime User
Thankyou airec, now I have to figure out how to take care of the response data maybe I will return with a more questions.
 
Upvote 0
Solution
Top