I need send a block of json in a post situation.
How could I do that, I did a lot of tries like below
First Try
second try
I need do something like that but i really can´t send the post with a json some one know how do that?
He send a json and recive back a json.
Thank
How could I do that, I did a lot of tries like below
First Try
B4X:
Sub Button1_Click
Dim job2 As HttpJob
'Send a POST request
job2.Initialize("Job2", Me)
job2.PostString("http://www.mysite/users/sign_in/", "[email protected]&password=pass")
End Sub
Sub JobDone(job As HttpJob)
ProgressDialogHide
If job.Success Then
ToastMessageShow ("SuccessFully Finish !", True)
json.Initialize(job.GetString)
'ShowData
Log(job.GetString)
job.Release
Else
Msgbox(job.ErrorMessage, "Error")
End If
End Sub
B4X:
Sub Button1_Click
Dim job1, job2, job3 As HttpJob
'j.Download2("http://www.mysite/users/sign_in", Array As String("email", ""))
'Send a POST request
job2.Initialize("Job2", Me)
'job2.PostString.SetContentType("application/json")
Dim text As String
text = "{'email':'user@','password':'p@ss'}"
'job2.PostString("http://www.mysite/users/sign_in", text)
job2.Download2("http://www.mysite/users/sign_in", Array As String ( "email","user@","password","p@ss"))
' job2.GetRequest.SetContentType("application/json")
'Send a GET request
' job3.Initialize("Job3", Me)
' job3.Download("http://www.mysite/users/sign_in?email=shopping@mysite&password=p@ss")
End Sub
B4X:
Sub JobDone(job As HttpJob)
ProgressDialogHide
If job.Success Then
ToastMessageShow ("SuccessFully Finish !", True)
json.Initialize(job.GetString)
'ShowData
Log(job.GetString)
job.Release
Else
Msgbox(job.ErrorMessage, "Error")
End If
End Sub
I need do something like that but i really can´t send the post with a json some one know how do that?
He send a json and recive back a json.
Thank
B4X:
- curl -H 'Content-Type: application/json' -H 'Accept: applicatíon/json' -X POST http://www.mysite/users/sign_in -d '{"user": {"email": "user@", "password": "p@ss"}}'
{"id": 2 ,"email":"asd","segment":null,"authentication_token":"eLBJjasd9as7_9871923"}^
~ I
Last edited: