Tuesday, 15 September 2015

delphi - How to send a json string with http post with synapse lib? -


I am using synapse lib and I want to send a PHP API to a string via http post.

This is my last Jason string that I want to send from the http post to the API. "", "Version": "3.22", "name": "Windows 7", "architecture": "64", "date": "20.06.2013", "version": " TestVM-PC "} var sSendString: String; "" "": "Windows 7", "architecture": "64", "Date": "20.06.2013", "Version": "3.22", "Name": "Testv-pc"};

I got this sample process to post the parameter, but I do not know how to properly send a JSON string (sSendString) in the API.

  Process HTTPPost; Var URL: String; Paramah: String; Response: TMemoryStream; Start the Response: = TMemoryStream.Create; Try the URL: = 'http://testserver.com/ Api / add_customer '; param: =' parameter1 = '+ encodermment ('Data1') + '& amp; +' parameter2 = '+ encoded credentials (' data2 '); If HttpPostURL (URL, Ultimate, Response) then Response. SaveToFile (' c: \ response.txt '); Finally, answer.free; finished; end;   

Then someone helps me fix my problem and can show me which lines to send an API to my JSSN string Thanks in advance.

I use synapse in my projects too So am I working with Synapse to simplify and speed, I wrote THTTPSendEx class, which provides high-speed access and features minimal code and more. Currently it is a beta version

It is an idea like indie

Create onTrpsendEx classes on OnBeginWork, OnWork, OnWorkEnd prototype (see PAS file), and assign it to the created class Please. Which is essential for you to pinpoint the progress of HTTP requests, and only call GET, the class post function. Apart from this, the class is very easy, "Like Indy", GET methods, post requests with many different input and output data types. Try it.

If you have any ideas for this, please write this as a comment on the project page.

Sorry for the mistakes in English.

No comments:

Post a Comment