Android Question HttpUtils PostString not working

RhodesB4A

Member
Licensed User
Longtime User
Hi all,
Basically I'm attempting to post data to the URL expecting a JSON object. But i keep hetting the "Error: not found" message. Any ideas on why It's not working please?

B4X:
Sub justrun
   
        Dim postProdJob As HttpJob
        Dim m As Map
        postProdUrl = "http://146.231.88.170:8080/reedhousesystemsitsafricaweb/service/art/add-product/"     
       
        m.Initialize
        m.Put("id", 1)
        m.Put("profile", "Frank Lucas")
        m.Put("name", "Zululand")
        m.Put("dimension", "4 x 5 x 7")
        m.Put("price", 550)
        m.Put("description", "NA")
        m.Put("type", "Carving")
        m.Put("quantity", 4)
       
        Dim JSONGenerator As JSONGenerator
        JSONGenerator.Initialize(m)     
       
      postProdJob.Initialize("PostProd", Me)
      postProdJob.PostString(postProdUrl, JSONGenerator.ToString())
                     
      postProdJob.Release               

End Sub

Sub JobDone (Job As HttpJob)
    Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
    If Job.Success = True Then
        Select Job.JobName
            Case "PostProd"               
                Log(Job.GetString)                   
        End Select
    Else
        Log("Error: " & Job.ErrorMessage)
        ToastMessageShow("Error: " & Job.ErrorMessage, True)
    End If
    Job.Release
End Sub
 

RhodesB4A

Member
Licensed User
Longtime User
Fixed again. I added postProdJob.GetRequest.SetContentType("application/json") after the postString line.

Now my Log error is
"add failed : org.hibernate.PersistentObjectException: detached entity passed to persist: com.reedhousesystems.core.services.persistence.entities.Product". Where am I going wrong?
 
Upvote 0
Top