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

前端 未结 3 1320
迷失自我
迷失自我 2020-12-01 01:53

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 th

3条回答
  •  忘掉有多难
    2020-12-01 02:30

    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;
      try
        Result := lHTTP.Post('http://blahblahblah...', lParamList);
      finally
        lHTTP.Free;
        lParamList.Free;
      end;
    end;
    

提交回复
热议问题