Android Question PUT HttpJob with Header / Json

victormedranop

Well-Known Member
Licensed User
Longtime User
I need to connect to a customer to consume a web service. I need to change the header to add users login. Must be a PUT connection and put an Json string. I try this with no luck.

B4X:
Dim cancelJOB As HttpJob
 cancelJOB.Initialize("quickpickJOB",Me)
 Try
 Dim Data As List
 Data.Initialize
 
 Data.Add("RetailId:"&aditional.reatilid)
 Data.Add("TerminalId:"&aditional.terminalid)
 Data.Add("Serial:"&aditional.XSerial)
 Data.Add("ValidationCode:"&aditional.XSerial)
 Dim JSONGenerator As JSONGenerator
 JSONGenerator.Initialize2(Data)
 Msgbox(JSONGenerator.ToPrettyString(2), "")
 
 cancelJOB.Download("https://XXgXXFFFFFFn.do/DDDDD/CanFFFFFFet/")
 Dim cancel_string As String = JSONGenerator.ToPrettyString(2), ""
 LogColor(cancel_string,Colors.Red)
 cancelJOB.GetRequest.SetHeader("Login",aditional.login)
 cancelJOB.GetRequest.SetHeader("PassWord",aditional.password)
 cancelJOB.PostString("https://XXgXXFFFFFFn.do/DDDDD/CanFFFFFFet/",cancel_string)
 Catch
 Log(LastException)
 End Try

Sub JobDone (Job As HttpJob)
 Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
 Dim parser As JSONParser
 If Job.Success = True Then
 Select Job.JobName
 
 Case "cancelJOB"
 Log(Job.GetString)
 Case "Job4"
 
 End Select
 Else
 Log("Error: " & Job.ErrorMessage)
 ToastMessageShow("Error: " & Job.ErrorMessage, True)
 End If
 Job.Release
 StartActivity(QuicPick_Result)
End Sub
 
Top