我使用了 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);
但有什么不对劲。例如,当我运行它时,它会发出错误 [[DCC Error] consoleHttp.dpr(29): E2010 不兼容类型:'字符串'和'过程、非类型化指针或非类型化参数']
的警报 s:=http.Post('http://test.me',geo,response)
。我做错了什么?
最佳答案
此错误意味着您向方法 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;
但没有一个与您传递的参数匹配。
关于Delphi错误E2010不兼容的类型: 'string' and 'procedure, untyped pointer or untyped parameter' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8176926/