Android Question Json Post Error

Puthut Wibowo

Member
Licensed User
Hi everyone,
I'm trying to Post JSON to a URL.
here is the code that I use

B4X:
    Dim dataawal,dataakhir As String
    
    dataawal="2024-04-01"
    dataakhir=2024-05-01
    
    Dim MapMain As Map = CreateMap ("symbols": $"["${Symbol}"]"$, "intervals": $"["1day"]"$, "methods": $"["time_series"]"$)
    JSONGenerator.Initialize(MapMain)
    Log(JSONGenerator.ToPrettyString(5).Replace("\", "").Replace("""[", "[").Replace("]""", "]")) 'REMOVE UNNECESSARY CHARACTERS

    Dim J As HttpJob
        J.Initialize(Null, Me)
    
    j.PostString("https://api.goapi.io/stock/idx/AGRO/historical?from=${dataawal}&to=${dataakhir}&api_key${Twelvedata_APIKey}",JSONGenerator.ToString.Replace("\", "").Replace("""[", "[").Replace("]""", "]")) 'REMOVE UNNECESSARY CHARACTERS
    j.GetRequest.SetContentType("application/json; charset=UTF-8")

    Wait For (J) JobDone(j As HttpJob)
    If J.Success Then
        
        ChartTickerPrice.Visible = True 'Unhide the chart
        PanInfo.Visible = True 'Unhide the information panel
        Log(J.GetString)
        
        ChartTickerPrice.Visible = True 'Unhide the chart
        
        
            ParseTickerData(J.GetString) 'Parge the company ticker JSON data
            End If
    j.Release

and Error Messages
B4X:
ResponseError. Reason: , Response: {"status":"error","message":"The POST method is not supported for route stock\/idx\/AGRO\/historical. Supported methods: GET, HEAD."}

Does anyone know why the error occurs, where is the error?

Thank You
 
Top