Delphi错误E2010不兼容类型:“字符串”和“过程、非类型指针或非类型参数”

Delphi错误E2010不兼容类型:“字符串”和“过程、非类型指针或非类型参数”,delphi,console,indy,Delphi,Console,Indy,我用了TStringList和类似的东西: geo: TStringList; response: TStringStream; begin http:=tidhttp.Create(nil); try { TODO -oUser -cConsole Main : Insert code here } geo:=TStringList.Create; response:=TStringStream.Create(''); geo.Add('name=s

我用了TStringList和类似的东西:

geo: TStringList;
response: TStringStream;
  begin
  http:=tidhttp.Create(nil);
  try
    { TODO -oUser -cConsole Main : Insert code here }
    geo:=TStringList.Create;
    response:=TStringStream.Create('');
    geo.Add('name=stas');
    geo.Add('pass=431');
    s:=http.Get('http://test.me');
    writeln(http.ResponseText);
    writeln(s);
    s:=http.Post('http://test.me',geo,response);

但有点不对劲。例如,当我运行它时,它会发出警报,在s:=http.Post中出现错误[[DCC error]consoleHttp.dpr29:E2010不兼容的类型:'string'和'procedure,untyped pointer或untyped parameter']http://test.me",geo,回应。我做错了什么?

此错误表示您将错误的参数传递给了方法TIdHTTP.post。此方法有几个重载

function Post(AURL: string; ASource: TIdStrings): string; overload;
function Post(AURL: string; ASource: TIdStream): string; overload;
function Post(AURL: string; ASource: TIdMultiPartFormDataStream): string; overload;
procedure Post(AURL: string; ASource: TIdMultiPartFormDataStream; AResponseContent: TIdStream); overload;
procedure Post(AURL: string; ASource: TIdStrings; AResponseContent: TIdStream); overload;
procedure Post(AURL: string; ASource, AResponseContent: TIdStream); overload;

但是没有一个参数与您正在传递的参数匹配。

此错误意味着您正在将错误的参数传递给方法TIdHTTP.post。此方法有几个重载

function Post(AURL: string; ASource: TIdStrings): string; overload;
function Post(AURL: string; ASource: TIdStream): string; overload;
function Post(AURL: string; ASource: TIdMultiPartFormDataStream): string; overload;
procedure Post(AURL: string; ASource: TIdMultiPartFormDataStream; AResponseContent: TIdStream); overload;
procedure Post(AURL: string; ASource: TIdStrings; AResponseContent: TIdStream); overload;
procedure Post(AURL: string; ASource, AResponseContent: TIdStream); overload;
但是没有一个与您正在传递的参数匹配。

执行以下操作:

http.Post('http://test.me',geo,response);
而不是:

s:=http.Post('http://test.me',geo,response);
唯一匹配的方法是过程,但过程不返回值。错误消息表示无法将过程分配给字符串。

执行以下操作:

http.Post('http://test.me',geo,response);
而不是:

s:=http.Post('http://test.me',geo,response);

唯一匹配的方法是过程,但过程不返回值。错误消息表示无法将过程分配给字符串。

确切地说,不需要使用第三个参数。他似乎认为geo是一些http头,response是response?确切地说,不需要使用第三个参数。似乎他可能认为geo是一些http头,而response就是response?