vHttp := TNetHTTPClient.Create(nil);
vS := TStringStream.Create('', TEncoding.GetEncoding(65001));
try
vS.Clear;
with vHttp do
begin
ConnectionTimeout := 2000;
ResponseTimeout := 10000;
AcceptCharSet := 'utf-8';
AcceptLanguage := 'en-US';
ContentType := 'application/json';
// UserAgent := 'Embarcadero URI Client/1.0';
CustomHeaders['Authorization'] :=
'Bearer ' + access_token;
CustomHeaders['X-EBAY-C-MARKETPLACE-ID'] := 'EBAY_US';
try
Get('
https://api.ebay.com/sell/fulfillment/v1/order?'
// + 'orderIds=' + vOrderIds
+ 'filter=' + TNetEncoding.URL.Encode(vFilter)
+ '&limit=' + vLimit
+ '&offset=' + vOffset, vS);
mmo2.Lines.Text := TNetEncoding.URL.URLDecode(vS.DataString);
except
on E: Exception do
mmo2.Lines.Text := 'error:' + E.Message;
end;
end;
finally
vS.Free;
vHttp.Free;
end;
File, you can see if the interface supports formdata.
procedure TfrmMain.Button1Click(Sender: TObject);
var
cHttp: TNetHTTPClient;
vData: TMultipartFormData;
vRsp: TStringStream;
i: Integer;
begin
if OpenDialog1.Execute then
begin
cHttp := TNetHTTPClient.Create(nil);
vRsp := TStringStream.Create('', TEncoding.GetEncoding(65001));
try
for i := 0 to OpenDialog1.Files.Count - 1 do
begin
vData := TMultipartFormData.Create;
try
vData.AddFile('fname', OpenDialog1.Files.Strings
);
vData.AddField('utt', LabeledEdit1.Text);
with cHttp do
begin
ConnectionTimeout := 2000;
ResponseTimeout := 10000;
AcceptCharSet := 'utf-8';
AcceptEncoding := '65001';
AcceptLanguage := 'zh-CN';
ContentType := 'multipart/form-data';
UserAgent := 'Embarcadero URI Client/1.0';
try
Memo1.Lines.Add('upload file : ' + OpenDialog1.Files.Strings);
Post('http://localhost:8833/upfile', vData, vRsp);
Application.ProcessMessages;
except
on E: Exception do
Memo1.Lines.Add('Error:' + E.Message);
end;
Memo1.Lines.Add(vRsp.DataString);
end;
finally
vData.Free;
end;
end;
finally
cHttp.Free;
vRsp.Free;
end;
end;
end;