Atozed Forums
idHTTP.Delete does not support body data - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Indy (https://www.atozed.com/forums/forum-8.html)
+--- Forum: Indy General Discussion (https://www.atozed.com/forums/forum-9.html)
+--- Thread: idHTTP.Delete does not support body data (/thread-1470.html)



idHTTP.Delete does not support body data - wolfgang@koeppner-bures.at - 01-04-2020

Hi!
 idHTTP.Delete has no parameter to accept body data while e.g. spotify asks for some: 
https://developer.spotify.com/console/delete-playlist-tracks/

can this be added sometime?

Thanks


RE: idHTTP.Delete does not support body data - rlebeau - 01-07-2020

The TIdHTTP.Delete() method is just a thin wrapper for the protected TIdHTTP.DoRequest() method, which has an ASource parameter that TIdHTTP.Delete() sets to nil. You can simply call the DoRequest() method directly with your desired body data, eg:

Code:
type
  TIdHTTPAccess = class(TIdHTTP)
  end;

var
  Data: TStringStream;
begin
  Data := TStringStream.Create('... body data here ...', TEncoding.UTF8);
  try
    TIdHTTPAccess(IdHTTP1).DoRequest(Id_HTTPMethodDelete, 'https://api.spotify.com/v1/playlists/{playlist_id}/tracks', Data, nil, []);
  finally
    Data.Free;
  end;
end;

I have opened a ticket in Indy's issue tracker to add new overloads to TIdHTTP.Delete() for sending body data:

#277 Add overload for TIdHTTP.Delete() to send body data


RE: idHTTP.Delete does not support body data - wolfgang@koeppner-bures.at - 01-07-2020

Yes, that's what I did. :-)

Thanks for taking this a level further :-)