Android Question POST JSON ISSUE

hi guys, trying to post a json for an api.. tried to do exactly as per the httputils guide and tweaked as per most forum suggestions but couldn't find any result..(not getting any response, it doesnt go beyond wait for i suppose..) can anyone please point out what am i doing wrong.. below is my exact code if you wanna try out..
thanks in advance

myCode:
Dim job As HttpJob
    Dim Map1 As Map
    Map1.Initialize
    Map1.Clear
    Map1.Put("key","eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJtYWlsSWRlbnRpdHkiOiJjeWJlcmRvY2dwYXlAZ21haWwuY29tIn0.GMdUQIpxRytu1LXZWjZtkiKOauNUadNODNXVjh5VHCg")
    Dim JSON As JSONGenerator
    JSON.Initialize(Map1)
    Dim data As String =   JSON.ToPrettyString(0) ' JSON.ToString()
    Log(data)
    job.Initialize("getind",Main)
    job.PostString("https://data.geoiq.io/dataapis/v1.0/covid/availablecities",data)
    job.GetRequest.SetContentType("application/json")
    Wait For (job) JOBDone(job As HttpJob)
    Log(job.Response)
    If job.Success Then
        Log(job.GetString)
    End If
    job.Release
 
Please follow the tutorial.

The following is not correct.
B4X:
    job.Initialize("getind",Main)

original code:
 Dim j As HttpJob

   j.Initialize("", Me) 'name is empty as it is no longer needed

   j.Download("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand")

tried with empty name and Me object and got it working.. Thanks a lot......
 
Upvote 0
Why are you using Download (GET) if you want to send a POST request?
final:
Dim job As HttpJob
    Dim Map1 As Map
    Map1.Initialize
    Map1.Clear
    Map1.Put("key","eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJtYWlsSWRlbnRpdHkiOiJjeWJlcmRvY2dwYXlAZ21haWwuY29tIn0.GMdUQIpxRytu1LXZWjZtkiKOauNUadNODNXVjh5VHCg")
    Dim JSON As JSONGenerator
    JSON.Initialize(Map1)
    Dim data As String =   JSON.ToPrettyString(0) ' JSON.ToString()
    Log(data)
    job.Initialize("",Me)
    job.PostString("https://data.geoiq.io/dataapis/v1.0/covid/availablecities",data)
    job.GetRequest.SetContentType("application/json")
    Wait For (job) JOBDone(job As HttpJob)
Got it working.. Thanks everyone!!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…