http delete

Corticus

Well-known Member
Joined
Apr 30, 2002
Messages
1,579
Hi all,

I'm trying to submit an HTTP DELETE.
My POST is working and my GET is working fine.

Here's what I have for the DELETE which is not working:
Code:
Public Function deleteHTTP(ByVal URL, message) As String

    Dim HTTPobj As WinHttp.WinHttpRequest

    Set HTTPobj = New WinHttp.WinHttpRequest
    
    With HTTPobj
        .Open "DELETE", URL
        .send
    End With

    deleteHTTP = HTTPobj.responseText

End Function

It is possible that my code is ok, and that the server is not handling properly, but that's less likely considering I've never done a DELETE from VBA.

For what it's worth, the stderrout is this:
servlet.PageNotFound:183 - Request method 'DELETE' not supported

I think the problem is that I used my POST code and just changed POST to DELETE and removed the message body. That's probably not going to hack it, I suspect.

Thanks.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Going on the response, my money would be on the server not supporting the Delete verb. Are you sure it definitely does? - the code looks fine
 
Upvote 0
I talked to the developer writing the backend services, he thinks it is on his end.
Thanks for taking a look!
 
Upvote 0
I noticed I am getting different messages in stderrout depending on how I try to delete.
That makes me think I may be doing something wrong.

Which one of these should I be using?
Code:
Public Function deleteHTTP1(ByVal URL) As String

    Dim HTTPobj As WinHttp.WinHttpRequest

    Set HTTPobj = New WinHttp.WinHttpRequest
    
    With HTTPobj
        .Open "DELETE", URL
        .send
    End With

    deleteHTTP1 = HTTPobj.responseText

End Function
or
Code:
Public Function deleteHTTP2(ByVal URL) As String

    Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
    objHTTP.Open "DELETE", URL, False
    objHTTP.setRequestHeader "User-Agent", "Apache-HttpClient/4.1.1 (java 1.5)"
    objHTTP.send

    Response = objHTTP.responseText

    deleteHTTP2 = Response

End Function

It could be "none of the above".
 
Upvote 0

Forum statistics

Threads
1,223,927
Messages
6,175,432
Members
452,641
Latest member
Arcaila

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top