Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
idHTTP.Delete does not support body data
#1
Hi!
 idHTTP.Delete has no parameter to accept body data while e.g. spotify asks for some: 
https://developer.spotify.com/console/de...st-tracks/

can this be added sometime?

Thanks
Reply
#2
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

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

Thanks for taking this a level further :-)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)