i facing problem in inserting rows in database table through download2 or poststring method,
can anyone help me to find the mistake in the fallowing code, thanks in advance
B4X:
Dim job_5 As HttpJob
job_5.Initialize("job_5", Me)
job_5.Download2("http://192.168.1.7/posapi/insertKot/addkot", _
Array As String("kotno","'1'","itemcode","abc","itemcategory","food","unqno",2,"reason","","rate",21,"amount",21,"quantity",1,"taxrate",3,"preferencepckey",123,"kotdate",DateTime.Now,"status","A","itempckey",1234))
Do you have a return error?
Using this strategy there are two sides to put together, the client and the server. If the server is bad also the client will result not working.
about ErrorMessage returned from server if you use wait for instead of event
B4X:
Dim HttpJob1 As HttpJob
HttpJob1.Initialize("",Me)
HttpJob1.PostString("https://abc.def.com/command1",JSON)
HttpJob1.GetRequest.SetContentType("application/json")
Wait For (HttpJob1) JobDone(HttpJob1 As HttpJob)
If HttpJob1.Success Then
Log(HttpJob1.GetString)
' = HttpJob1.GetString
Else
' = HttpJob1.ErrorMessage
ToastMessageShow(HttpJob1.ErrorMessage,True)
Return
End If
HttpJob1.Release
Unless something major goes wrong on the server side, the server is probably still going to return a status code of 200 (meaning, Job.Success = True) and the error message is going to be in Job.GetString. Note: Rename Job to whatever variable name you gave your HTTPJob.