Android Question Help to build an HTTP post

marcick

Well-Known Member
Licensed User
Longtime User
This websyte provide coordinates of a GSM cell, making an HTTP post and passing cell data Mcc, Mnc, Lac and CI.

I have some sintax difficulties writing the code ....
These are instructions:

B4X:
curl --request POST \
  --url https://us1.unwiredlabs.com/v2/process.php \
  --data '{"token": "your_API_token","radio": "gsm","mcc": 310,"mnc": 410,"cells": [{"lac": 7033,"cid": 17811}],"wifi": [{"bssid": "00:17:c5:cd:ca:aa","channel": 11,"frequency": 2412,"signal": -51}, {"bssid": "d8:97:ba:c2:f0:5a"}],"address": 1}'

Any help is appreciated ....
 

DonManfred

Expert
Licensed User
Longtime User
something like

B4X:
    Dim j As HttpJob
    j.Initialize("",Me)
    Dim values As Map
    values.Initialize
    values.Put("token",AccessToken)
    values.Put("radio","GSM")
    values.Put("mcc",310)
    values.Put("mnc",410)
   
    Dim cells As List
    cells.Initialize
    cells.Add(CreateMap("lac": 7033, "cid": 17811))
   
    values.Put("cells",cells)
   
    Dim wifi As List
    wifi.Initialize
    wifi.Add(CreateMap("bssid": "00:17:c5:cd:ca:aa","channel": 11,"frequency": 2412,"signal": -51))
    wifi.Add(CreateMap("bssid": "d8:97:ba:c2:f0:5a"))
   
    values.Put("wifi",wifi)
    values.Put("address",1)

    j.PostMultipart("https://us1.unwiredlabs.com/v2/process.php",values,Null)
    wait for (j) JobDone(job As HttpJob)
    If job.Success Then
        Dim response As String = job.GetString
        Log(response)      
    Else
        Log(job.ErrorMessage)
    End If

Maybe @MarkusR is right and you need to build a json and then use job.Poststring(...)
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
Upvote 0
Top