I am trying to call eBay API through Delphi. After long time searching through Google and StackOverflow, I can get "GeteBayTime" (Shopping API) and "findItemsByKeywords" (Finding API) work properly now.
When I started to test with Trading API, I have no idea where and how to insert seller's account info (userid and password). My first program for trading API is shown below and it is started with API call "GetSellingManagerSoldListings".
Can any one show me some clue to make Trading API work? And if anything else needs to be added to HTTP.header or Paramters?
Thanks.
procedure TForm1.btnEBayGetSoldListClick(Sender: TObject);
var
sURL, sResponse, sEndpoint: String;
jResult: TJSONObject;
sCallName, sSiteID, sVersion: String;
k: Integer;
sParameters: String;
sHeaders: TStringList;
sRequestBody: TStringStream;
begin
// Trading API
sEndpoint := 'https://api.sandbox.ebay.com/ws/api.dll';
sCallName := 'GetSellingManagerSoldListingsRequest';
sSiteID := '15';
sVersion := '967';
sAppID := 'myAppID';
sDevID := 'myDevID';
sToken : 'myToken'; // OAuth Token?
sURL := sEndpoint
+ '?callname=' + sCallName
+ '&siteid=' + '15';
sHeaders := TStringList.Create;
with sHeaders do begin
Add('X-EBAY-API-COMPATIBILITY-LEVEL' + '=' + sVersion);
Add('X-EBAY-API-DEV-NAME' + '=' + sDevID);
Add('X-EBAY-API-APP-NAME' + '=' + sAppID);
Add('X-EBAY-API-CERT-NAME' + '=' + sCertID);
Add('X-EBAY-API-CALL-NAME' + '=' + sCallName);
Add('X-EBAY-API-SITEID' + '=' + sSiteID);
end;
objHTTP.Request.ContentType := 'text/xml';
with objHTTP.Request.CustomHeaders do begin
Clear;
AddStdValues(sHeaders);
end;
sHeaders.Free;
sParameters := '<GetSellingManagerSoldListingsRequest xmlns="urn:ebay:apis:eBLBaseComponents">'
+ ' <RequesterCredentials>'
+ ' <eBayAuthToken>' + sToken + '</eBayAuthToken>'
+ ' <Filter>' + 'PaidNotShipped' + '</Filter>'
+ ' </RequesterCredentials>'
+ '</GetItemTransactionsRequest>';
sRequestBody := TStringStream.Create(sParameters, TEncoding.UTF8);
try
sResponse := objHTTP.Post(sURL, sRequestBody);
memHTML.Lines.Add(sResponse);
memHTML.Lines.Add('');
except
sResponse := objHTTP.ResponseText;
memHTML.Lines.Add(sResponse);
memHTML.Lines.Add('');
end;
end;