iOS Question upload with json to a server

Ju Yang

Active Member
Licensed User
Longtime User
when i send a string of json to a server,it shows 400 error
Code: Copy
Sub Button1_Click
   dim a as map
    a.Initialize
    a.Put("username","hilee")
    a.Put("password","123456")
    a.Put("email","[email protected]")
    a.Put("nickname","kk")
    a.Put("firstname","wang")
    a.Put("lastname","uu")
    a.Put("photo","http://www.freetalk.com/photo/12345")

    Dim jssonp As JSONGenerator
    jssonp.Initialize(a)
    sname=jssonp.ToString
    Log(sname)
    Dim b As HttpRequest
    File.Copy(File.DirAssets,"smiley.png", File.DirDocuments, "smiley.png")

    b.InitializePost2("http://58.246.1.146:16040/users",sname.GetBytes("UTF8"))

    b.SetContentType("application/json")
    Dim h As HttpClient
    h.Initialize("h")
    h.Execute(b,1)
    Log("click")
End Sub

Sub h_ResponseSucce (Response As HttpResponse, TaskId As Int)
    Log("response success")

End Sub
Sub h_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
Log(Response.GetString)
    Log("Error response: " & Response.GetString & ", status code: " & StatusCode)

End Sub
my server api type :
{
"username": "",
"password": "123456",
"email": "[email protected]",
"nickname": "kk",
"firstname": "123",
"lastname": "5657"
}
the error :
Error response: , status code: 400
 
Last edited:
Back
Top