Android Question OkHttpUtils2 DELETE Method (for dummies)

pjetson

Member
Licensed User
Longtime User
I am aware of the thread from a few months back on this subject, but the forum tips advise me to start a new thread.

I also need HTTP DELETE, but I'm unfortunately not as clever as the other posters in that thread and I need a little more guidance.

I've downloaded the source code from the link that Erel posted. I unzipped the file and found two files with the name HttpJob.bas that (with a brief examination) appear to be the same. Which one of these two files do I need to modify?

I found this code, which I presume is the HttpJob.Download sub referred to:
B4X:
Public Sub Download(Link As String)
  req.InitializeGet(Link)
  CallSubDelayed2(HttpUtils2Service, "SubmitJob", Me)
End Sub

From Erel's post, it seems that I need to add a new sub using code like this:
B4X:
Public Sub Delete(Link As String)
  req.InitializeDelete(Link)
  CallSubDelayed2(HttpUtils2Service, "SubmitJob", Me)
End Sub

But then what do I do exactly? I suspect that I have to compile the modified HttpJob.bas file into a library, and then replace the existing library, but the HttpJob.bas file doesn't seem to have the right file name.

Thanks, Peter
 

DonManfred

Expert
Licensed User
Longtime User
Download the src zip from the okhttputils thread and extract the files.
Open this project and do the chnges here.

Add the sub to the HttpJob module from the project.

Compile the project as library.

The lines
B4X:
    #LibraryVersion: 2.20
    #LibraryName: OkHttpUtils2
#
in the main module set the name and version of the resulting library.

At the end you now have a new okhttputils2 library... Give it another name if you prefer.
 
Upvote 0

pjetson

Member
Licensed User
Longtime User
Thanks, Don.

I get three error messages when I "compile to library", but two of them seem straightforward and I think I have dealt with them properly. One of the errors is that the JavaObject library is included but not used, and the other asked me to remove a line from the manifest.xml file.

The third error message has me worried, though - it says "File 'httpjob.bas' is not used. (warning #15)". Since httpjob.bas is the file I've added the HttpJob.Download sub to, isn't that a problem?

Erel, what do you mean by "just use the two modules instead of the library"?

Peter
 
Upvote 0

lucad

Member
Licensed User
Longtime User
This worked for me

B4X:
Public Sub Delete(Link As String)

    Dim job_cancella_item As HttpJob
    job_cancella_item.Initialize("job_cancella_item",Me)
    job_cancella_item.PostString(Link,"")
    job_cancella_item.GetRequest.InitializeDelete(Link)
                  
End Sub
 
Upvote 0
Top