Hi everyone,
I have a problem calling a web service, to retrieve the value of message in case of trouble.
If the return of the call is good, job1.Getstring is ok (I can retrieve my token)
If the return is Bad Request, job1.Getstring is not initialised and I get this error:
In the same time, in my log screen, I can see this:
How can I retrieve this message in my Job1 ?
Here is my code:
I have a problem calling a web service, to retrieve the value of message in case of trouble.
If the return of the call is good, job1.Getstring is ok (I can retrieve my token)
If the return is Bad Request, job1.Getstring is not initialised and I get this error:
java.io.FileNotFoundException: /data/user/0/XXXXXX.V1/cache/1: open failed: ENOENT (No such file or directory)
In the same time, in my log screen, I can see this:
** Service (httputils2service) Create **
** Service (httputils2service) Start **
{
"message": "Invalid login / password or no rights on this activity."
How can I retrieve this message in my Job1 ?
Here is my code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Intro")
Dim URL As String = "http://xxxxxxxxxxxxxxxx.com/wsapi/api/common/auth/login/"
Dim M1 As Map
M1.Initialize
M1.Put("username","User1")
M1.Put("password","Pwd1")
M1.Put("activity",40)
Dim JSONGenerator As JSONGenerator
JSONGenerator.Initialize(M1)
Log(JSONGenerator.ToPrettyString(2))
Dim Job As HttpJob
Job.Initialize("Intro", "Main")
Job.PostString (URL, JSONGenerator.ToPrettyString(2))
Job.GetRequest.SetContentType("application/json")
End Sub
Sub JobDone(Job1 As HttpJob)
Msgbox(Job1.GetString,"")
Job1.Release
End Sub