Recent

Author Topic: Consume an API with Lazarus + Synapse  (Read 1948 times)

Odacir

  • New Member
  • *
  • Posts: 41
Consume an API with Lazarus + Synapse
« on: January 30, 2020, 05:45:55 pm »
Hello,

I'm trying connect / use an API from a service in Lazarus (and OS X), but things don't go ahead.

Its my first contact trying to use an API on Lazarus.

The api is from:
http://api.proofhq.com

I tryed connect to start with this code, but return error 500

Code: Pascal  [Select][+][-]
  1. var
  2.   http: THTTPSend;
  3.   Url: string;
  4. begin
  5.   http := THTTPSend.Create;
  6.   Url := 'https://soap.proofhq.com/19_2_6/soap.wsdl';
  7.   if not http.HTTPMethod('GET', Url) then
  8.     begin
  9.       ShowMessage(http.Headers.text + #13 + '(' + IntToStr(http.ResultCode) + ')' + http.ResultString);
  10.     end
  11.   else
  12.     begin
  13.       ShowMessage(http.Headers.text + #13 + '(' + IntToStr(http.ResultCode) + ')' + http.ResultString);
  14.     end;
  15.   http.Free;
  16. end;    

I added ssl_openssl in the uses but stay returning error 500.

What i doing wrong?


lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Consume an API with Lazarus + Synapse
« Reply #1 on: January 30, 2020, 06:00:46 pm »
For SOAP I use WST
https://wiki.freepascal.org/Web_Service_Toolkit

It has a tool to import the entire WSDL into classes (and maybe you need to tweak these classes a bit in order to work, but it finally works), and you can call the methods directly using classes to fill the data / retrieve the data in OOP way, without touching nothing of XML.

Odacir

  • New Member
  • *
  • Posts: 41
Re: Consume an API with Lazarus + Synapse
« Reply #2 on: January 30, 2020, 06:49:10 pm »
Hello lainz,

I will try to find a example / tutorial about the use of WST.
With the wiki i can't do nothing here :(

Thanks!

 

TinyPortal © 2005-2018