Hello,
I'm really enjoying B4A, I've been more productive in a week than 3 years in eclipse
I'm missing how I use httpUtils2 to send a JSON string to my web service.
I have tested the service with REST Console for Chrome, the string that this code produces works when sent as an application/json Content-Type.
This is the code that returns an Internal Server Error.
Also if there is a more elegant way to produce the JSON I'd like to hear it
Thank you
Russ
I'm really enjoying B4A, I've been more productive in a week than 3 years in eclipse
I'm missing how I use httpUtils2 to send a JSON string to my web service.
I have tested the service with REST Console for Chrome, the string that this code produces works when sent as an application/json Content-Type.
This is the code that returns an Internal Server Error.
B4X:
Sub PerformUpload ()
Dim mylist As List
mylist.Initialize
Dim m As Map
Dim Cursor1 As Cursor
Cursor1 = SQLObj.ExecQuery("SELECT name FROM people")
For i = 0 To Cursor1.RowCount - 1
Cursor1.Position = i
m.Initialize
m.Put("name",Cursor1.GetString("name"))
mylist.Add(m)
Next
Cursor1.Close
Dim j As JSONGenerator
j.Initialize2(mylist)
Msgbox(j.ToPrettyString(2), "")
'Send a POST request - this is where I'm struggling
Dim job As HttpJob
job.Initialize("SendAssets", Me)
job.PostString("http://myserver/servicething/api/People", j.ToString)
ToastMessageShow("Sending...", True)
End Sub
Also if there is a more elegant way to produce the JSON I'd like to hear it
Thank you
Russ