[Synalist] Trying to use an API with SSL and HTTP POST
Pascal TCP/IP Library
Brought to you by:
geby
|
From: Jeff C. <je...@as...> - 2016-03-31 00:30:24
|
Hi I'm new to Synapse - also new to writing web applications ... I have access to an API by which I can make request for data by HTTP POST's. I have used the Google App "Postman" and postings like:- https://my.xxxxxx.com/api/function1?clientid=2&clienttoken=ThisIsAGUID ... work correctly returning the expected data. I'll want to incorporate this in my Delphi program and am first writing a simple test bed. I have been through StackOverflow and the mailing list and found some sample code but I can't make it work. The actual code is posted below my signature. I do have libeay32.dll and ssleay32.dll in the same folder as my EXE. The error message that I get is "Winsock error #10091" Network subsystem is unusable Any help appreciated. Cheers Jeff -- procedure TfrmMain.btnGoClick(Sender: TObject); var sock: TTCPBlockSocket; s: string; begin sock := TTCPBlockSocket.Create; try sock.Connect(EncodeURL('https://my.xxxxxxx.com/api'), '443'); sock.SSLDoConnect; if sock.lasterror <> 0 then // check for success start of SSL begin sock.ExceptCheck; Showmessage('Winsock error #' + IntToStr(sock.lasterror) + CRLF + CRLF + sock.LastErrorDesc); exit; end; sock.SendString('POST function1?clientid=' + EncodeURLElement('2') + '&clienttoken=' + EncodeURLElement ('ThisIsAGUID') + CRLF); s := sock.recvstring(15000); Showmessage(s); finally sock.Free; end; end; |