You simply use the Indy TIdHTTP component and call the Post method. Pass the URL as the first argument and the JSON string as the second argument. More or less like this:
procedure TForm1.Button1Click(Sender: TObject); var jsonToSend: TStringList; http: TIdHTTP; begin http := TIdHTTP.Create(nil); try http.HandleRedirects := True; http.ReadTimeout := 5000; jsonToSend := TStringList.create; try jsonToSend.Add('{ Your JSON-encoded request goes here }'); http.Post('http://your.restapi.url', jsonToSend); finally jsonToSend.Destroy; end; finally http.Destroy; end; end;
I assume that you can already encode and decode JSON, and that you were just asking how to do HTTP publishing using Delphi.
Jeff wilhite
source share