Archived Forum Post

Index of archived forum posts

Question:

How to Submit HTTP Delete Request?

Sep 18 '14 at 08:26

If I want to submit a custom HTTP request (DELETE), what's the proper/best way? I tried doing a PostUrlEncoded() after creating a HttpRequest object with the HttpVerb set to "DELETE", but didn't have any luck as the Http class still uses POST as the verb despite me setting the custom verb. Using Http.SynchronousRequest seems like the next best bet but I only see how to make domain-level queries; I tried inputting a full path (site.com/a/b/c) and it merged it all into site.comabc, stripping the slashes. So how can I make a HTTP DELETE request?


Answer

According to the HTTP protocol specifications, the following request methods (also known as verbs) never include a message body: GET, HEAD, DELETE. In other words, the Content-Length header is omitted because it is always 0. The reason I say this is because the QuickDeleteStr method should be sufficient to send any DELETE request. If custom header fields need to be added, then the SetRequestHeader method can be called once per custom header, prior to calling QuickDeleteStr.