What’s the simplest way to call Http POST url using Delphi?

Inspired by the question What’s the simplest way to call Http GET url using Delphi? I really would like to see a sample of how to use POST. Preferably to receive XML from the call.

Added: What about including an image or other file in the post data?

Answers


Using Indy. Put your parameters in a StringList (name=value) and simply call Post with the URL and StringList.

function PostExample: string;
var
  lHTTP: TIdHTTP;
  lParamList: TStringList;
begin
  lParamList := TStringList.Create;
  lParamList.Add('id=1');

  lHTTP := TIdHTTP.Create(nil);
  try
    Result := lHTTP.Post('http://blahblahblah...', lParamList);
  finally
    lHTTP.Free;
    lParamList.Free;
  end;
end;

Need Your Help

What is the best way of using WCF Service data structures

c# wcf

I'm creating a solution in C# using WCF Service. There is one project which has Service References set to My WCF Service, however I'll be using data structures from the server through multiple proj...

After publishing, my Umbraco admin panel did not show in IE9. But it appear in FF and Chrome browsers

asp.net website umbraco publishing-site

After publishing, my Umbraco admin panel did not show in IE9. But it appear in FF and Chrome browsers.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.