我尝试了几个在网上搜索如何用TIDHTTP发送DELETE请求但没有成功的例子......
我正在使用Delphi Indy 10.0.52.显然,在TIdHTTP对象中没有像Delete那样的方法.可能吗?我在这里错过了一些东西......救命!
我结束了这样的事情(不工作):
procedure TRestObject.doDelete( deleteURL:String );
var
res : TStringStream;
begin
res := TStringStream.Create('');
http := TidHTTP creation and init...
try
http.Request.Method := IdHTTP.hmDelete;
http.Put( deleteURL, res );
except
on E: EIdException do
showmessage('Exception (class '+ E.ClassName +'): ' + E.Message);
on E: EIdHTTPProtocolException do
showmessage('Protocol Exception (HTTP status '+ IntToStr(E.ErrorCode) +'): ' + E.Message);
on E: EIdSocketError do
showmessage('Socket Error ('+ IntToStr(E.LastError) +'): ' + E.Message);
end;
res.Free;
end;
Run Code Online (Sandbox Code Playgroud)
这是一个对象中已经处理GET,PUT,POST到使用django-tastypie实现的RESTful Web服务的方法.我在对象的init阶段中设置了所有权限和身份验证.