I try to emulate the same behavior like this console call:
# curl -X POST -F"file=@myfile.csv" 'https://myserver/upload'
Here is my Delphi 10.1 code:
procedure TForm1.Button1Click(Sender: TObject);
var localfile:String;
localpath:string;
begin
localfile := 'myfile.csv';
localpath := 'C:\upload';
SetCurrentDir(localpath);
RESTClient.ContentType:= 'multipart/form-data';
RESTClient.BaseURL:= 'https://myserver';
RESTRequest.Accept:= '*/*';
RESTRequest.Method:= rmPOST;
RESTRequest.Resource:= 'upload';
RESTRequest.AddParameter('file',localfile, TRESTRequestParameterKind.pkREQUESTBODY);
RESTRequest.Execute;
Memo1.Lines.Add(RESTResponse.Content);
end;
it fails with: 415 Unsupported Media Type