Android Question How to get json request value in B4A HTTPServer

Ganiadi

Active Member
Licensed User
Longtime User
Hi,
Please help how to get json request value in B4A.
I can do it in B4J, but dont know how do it in B4A

Code:
Sub b4jHandle(req As ServletRequest, resp As ServletResponse)
    Dim cBody As String
    Dim cAPIKey As String
    resp.ContentType = "application/json"   
    Try
        Dim data() As Byte = Bit.InputStreamToBytes(req.InputStream)
        Dim cJSON As String = BytesToString(data, 0, data.Length, "UTF8")
        Dim Json As JSONParser
        Dim Map1 As Map

        Json.Initialize(cJSON)
        Map1 = Json.NextObject

        cAPIKey = Map1.Get("apikey")
    
    Catch
        Log(LastException.Message)

    End Try
    
    cBody = "{""value"":""" & cAPIKey & """}"
        
    resp.Write(cBody)
End Sub

How do i do this below to b4a
Dim data() As Byte = Bit.InputStreamToBytes(req.InputStream)

Tks
 
Top