B4J Question HTTPJob JobDone not called for empty response body

jmon

Well-Known Member
Licensed User
Longtime User
Hello,

I'm working on a project that requires Google Calendar API. I manage to get a response from the POST and GET methods, but I don't from the DELETE method.

As you can see from this page : https://developers.google.com/google-apps/calendar/v3/reference/calendars/delete
Response
If successful, this method returns an empty response body.
delete returns an empty response. I don't get any feedback from my call, the JobDone event is never called.

My code is this:
B4X:
Dim job As HttpJob
job.Initialize("CalendarDelete", Me)
job.Tag = Tag
job.Delete("https://www.googleapis.com/calendar/v3/calendars/" & su.EncodeUrl(CalendarId, "UTF8") _
        & "?access_token=" & oAuthAccessToken)

Is there a way to get the feedback?

Thanks for your help.
Jmon.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You will need to modify HttpUtils2 source code with a small change.

Change hc_ResponseSuccess to:
B4X:
Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
   If Response.ContentLength = 0 Then
     CompleteJob(TaskId, True, "")
   Else
     Response.GetAsynchronously("response", File.OpenOutput(TempFolder, TaskId, False), _
       True, TaskId)
   End If
End Sub
 
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User

Thank you,

How to I do that? I opened the jar with 7z, and read the httpjob.class file but It looks obfuscated or something like that:


Thank you
 
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
So I've edited and compiled the code, I get an error:

Thank you
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This means that the web service didn't return the content length header.

You can use this line to get the HttpJob:
B4X:
Dim job As HttpJob = TaskIdToJob.Get(TaskId)

When you send a DELETE request set HttpJob.Tag to Delete. Now you can check the tag value in the ResponseSuccess sub and if it is Delete then call CompleteJob.
 
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
hum... it gives me an error if I release the Response:

In the original HttpUtils2, the response was not released.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…