B4J Question [SOLVED] req.GetParameter not retrieving values while req.ParameterMap does retrieve them

j_o_h_n

Active Member
Licensed User
I have two b4j programs, a server and a client
The client sends a post request.
Using the function PrintAllParameters i am able to retrieve the names and values of both parameters
However the GetParameter method just returns empty strings for both.
I think there is something wrong with the Text argument I am entering in the Poststring method on the client but I don't know what it is.

Client code:
[CODE=b4x]
Dim  job As HttpJob  'using jOKHttpUtils2
job.Initialize("job", Me)
Dim s As String = "firmid=Y1m & password=$2a$10$CpmIIvM0UqToZcP0iwKO9ugp4zlHwiNU7Pyo4dT1FFB9OfwQizgUO"
job.PostString(url,s)
Server code:
Log(PrintAllParameters(req))     'retrieves both parameters
Dim firmid As String = req.GetParameter ("firmid") 'empty string returned
Dim Password As String = req.GetParameter("password")  'empty string returned

Public Sub PrintAllParameters (req As ServletRequest) As String
    Dim sb As StringBuilder
    sb.Initialize
    sb.Append("<ul>")
    Dim params As Map = req.ParameterMap
    For Each name As String In params.Keys
        sb.Append("<li>").Append(name).Append(":")
        Dim values() As String = params.Get(name)
        For Each value As String In values
            sb.Append(" ").Append(value)
        Next
        sb.Append("</li>")
    Next
    sb.Append("</ul>")
    Return sb.ToString

End Sub



Log output:
<ul><li>firmid: Y1m </li><li> password: $2a$10$CpmIIvM0UqToZcP0iwKO9ugp4zlHwiNU7Pyo4dT1FFB9OfwQizgUO</li></ul>
 
Last edited:

Daestrum

Expert
Licensed User
Longtime User
It might be the spaces you added before and after the &
try it with
B4X:
Dim s As String = "firmid=Y1m&password=$2a$10$CpmIIvM0UqToZcP0iwKO9ugp4zlHwiNU7Pyo4dT1FFB9OfwQizgUO"
 
Upvote 0
Top