Open kidultttttt opened 9 months ago
We use another component: https://github.com/maxkleiner/HttpComponent And multipart :files works
`function TestHTTPClassComponentAPIDetection2(AURL, askstream, aApikey: string): string;
var HttpReq1: THttpRequestC;
Body: TMultipartFormBody;
Body2: TUrlEncodedFormBody;
begin
Body:= TMultipartFormBody.Create;
Body.ReleaseAfterSend:= True;
//Body.Add('code','2','application/octet-stream');
Body.AddFromFile('image', exepath+'randimage01.jpg');
HttpReq1:= THttpRequestC.create(self);
HttpReq1.headers.add('X-Api-Key:'+AAPIKEY);
HttpReq1.headers.add('Accept:application/json');
HttpReq1.SecurityOptions:= [soSsl3, soPct, soIgnoreCertCNInvalid];
try
if HttpReq1.Post1Multipart(AURL, body) then
writeln(HttpReq1.Response.ContentAsString)
else Writeln('APIError '+inttostr(HttpReq1.Response.StatusCode2));
finally
writeln('Status3: '+gethttpcod(HttpReq1.Response.statuscode2))
HttpReq1.Free;
sleep(200)
// if assigned(body) then body.free;
end;
end;
`
Hello! I'm trying to post an image. Unfortunately, the process doesn't work. The current routine is as follows. The problem is, the following exception is thrown: E2010 Incompatible types: 'string' and 'TObject' Shouldn't the post method receive such a parameter?