IanB Posted October 22, 2014 Share Posted October 22, 2014 Can someone give me an example of using Delphi (preferable TIdHttp) to access the PreastaShop API Cheers Link to comment Share on other sites More sharing options...
IanB Posted October 23, 2014 Author Share Posted October 23, 2014 After a LOT of experimentation and analyzing network captures the following works: procedure TForm7.DoOnAuthorization(Sender: TObject; Authentication: TIdAuthentication; var Handled: Boolean); begin Authentication.Username := ShopKey; Authentication.Password := ''; Handled := true; end; procedure TForm7.DoOnSelectAuthorization(Sender: TObject; var AuthenticationClass: TIdAuthenticationClass; AuthInfo: TIdHeaderList); begin AuthenticationClass := TIdBasicAuthentication; end; procedure TForm7.FormCreate(Sender: TObject); var SSLHandler: TIdSSLIOHandlerSocketOpenSSL; s: string; begin Client := TIdHttp.Create(self); Client.OnAuthorization := DoOnAuthorization; Client.OnSelectAuthorization := DoOnSelectAuthorization; Client.HTTPOptions := Client.HTTPOptions + [hoInProcessAuth]; Client.Request.Accept := ''; Client.Request.AcceptEncoding := ''; Client.Request.UserAgent := ''; s := Client.Get('http://mysite.com/api'); end; 1 Link to comment Share on other sites More sharing options...
LbAce Posted March 3, 2015 Share Posted March 3, 2015 Thank you for this code. It works fine. The GET for an product like s:= Client.Get('http://mysite.com/api/product/1'); works also. but the PUT doesn't work. have you any idea ? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now