Hi, Erel!
I'm not sure what I'm actuall doing wrong. I've created a simple test API to recieve a JSON string and created a simple android app to pass the string using HttpJob.Postring method. However, the method doesn't seem to pass the data to the web api.
The server returns an exception message: Value cannot be null...Parameter name: value
This happens as the API tries to deserialize the JSON string supposedly contained in parameter 'value', which was supposedly sent by the post method.
I've tried consuming the API using a different application and it works fine.
Here's the code that I used based on your example:
This is the exact JSONData that worked in the other app but not here:
[{"Data2":"test data 2","EmpID":"1234","Data1":"test data 1"},{"Data2":"test data 2","EmpID":"5678","Data1":"test data 1"},{"Data2":"test data 2","EmpID":"9012","Data1":"test data 1"}]
I've also revised the HttpJob code:
Still to no avail.
Hope you can point me to the right direction as I am at a loss.
Thank you once again for your usual support!
I'm not sure what I'm actuall doing wrong. I've created a simple test API to recieve a JSON string and created a simple android app to pass the string using HttpJob.Postring method. However, the method doesn't seem to pass the data to the web api.
The server returns an exception message: Value cannot be null...Parameter name: value
This happens as the API tries to deserialize the JSON string supposedly contained in parameter 'value', which was supposedly sent by the post method.
I've tried consuming the API using a different application and it works fine.
Here's the code that I used based on your example:
B4X:
Sub ButtonPost_Click
'Send a POST request
Dim job1 As HttpJob
job1.Initialize("Job1", Me)
job1.PostString("http://somesite/testapi/api/values", JSONData)
End Sub
This is the exact JSONData that worked in the other app but not here:
[{"Data2":"test data 2","EmpID":"1234","Data1":"test data 1"},{"Data2":"test data 2","EmpID":"5678","Data1":"test data 1"},{"Data2":"test data 2","EmpID":"9012","Data1":"test data 1"}]
I've also revised the HttpJob code:
B4X:
Public Sub PostBytes(Link As String, Data() As Byte)
req.InitializePost2(Link, Data)
'I inserted this line:
req.SetContentType("application/json")
CallSubDelayed2(HttpUtils2Service, "SubmitJob", Me)
End Sub
Still to no avail.
Hope you can point me to the right direction as I am at a loss.
Thank you once again for your usual support!