0

I'm trying to connect and get Access Token from eBay Sellers API.

I'm doing something wrong and I don't know what. I'm having RESTClient, RESTRequest, RESTResponse and button component on my form and I want to get access token on button click.

Here is my code:

procedure TForm5.btn1Click(Sender: TObject);
 var
  vClientId, vClientSecret : string;
  vBase64,vBase: String;
  vItem: TRESTRequestParameter;
  vRuNames, vIspravno, str : string;
  vOdgovor : string;
  vContent, vContent1: string;
 begin
   vClientId:='jackjump-proba-SBX-15d7a0307-68d66d5a';
   vClientSecret:=':SBX-5d7a03073f13-cb20-4a72-b71e-4e53';
   vBase:=vClientId+':'+vClientSecret;
   vBase64:='Basic '+TNetEncoding.Base64.Encode(vClientId+vClientSecret);
   vIspravno:='Basic amFja2p1bXAtcHJvYmEtU0JYLTE1ZDdhMDMwNy02OGQ2NmQ1YTpTQlgtNWQ3YTAzMDczZjEzLWNiMjAtNGE3Mi1iNzFlLTRlNTM=';
   vBase64 := StringReplace(vBase64, sLineBreak, '', [rfReplaceAll]);

   vRuNames:='jack_jumping-jackjump-proba--tbccomu';
   RESTClient1:=TRESTClient.Create('https://api.sandbox.ebay.com/');
   RESTRequest1.Resource:='identity/v1/oauth2/token';    
   RESTRequest1.AddParameter('Content-Type', 'application/x-www-form-urlencoded', pkHTTPHEADER);
   RESTRequest1.AddParameter('Authorization', vBase64, pkHTTPHEADER);
   vContent :='grant_type=client_credentials&redirect_uri=jack_jumping-jackjump-proba--tbccomu&scope=https://api.ebay.com/oauth/api_scope';
     RESTRequest1.Body.Add(vContent);
     RESTRequest1.Execute;
 end;

By clicking on the button I get/raise exception 500 internal server error.

Mika Sundland
  • 18,120
  • 16
  • 38
  • 50
  • Update your question with possible error code you received and some referral links you tried to solve it your own. – ZF007 Jan 15 '18 at 13:31
  • Sry i dont understand :( – Jack Jumping Jan 16 '18 at 14:41
  • What I ment: .. did you search [here](https://stackoverflow.com/questions/38805751/idhttp-error-500-internal-server-when-site-is-https) or tried to find answers [here](https://forums.developer.ebay.com/questions/15871/getting-internal-server-error.html)? Just show some effort you took in solving it yourself. This helps others to get motivated and help you much faster and nail down what's not it that throws this error 500. – ZF007 Jan 16 '18 at 15:02
  • ZF007 tnx for explanation and for the links (second one i was already looking), im kind a new to this (programing&stackoverfllow). TNX – Jack Jumping Jan 16 '18 at 16:29

0 Answers0