I need interact with a rest api server. I found it is easy to send get request with fphttpclient:
function ReadURLGet(url:string):string;
begin
with TFPHTTPClient.Create(nil) do
try
ReadURL:= Get(url);
finally
Free;
end;
end;
Since server answer is always a Json format string, it works perfect for me. But how about post request? Is there any simple way with fphttpclient? Something like:
function ReadURLPost(url:string;data:array):string;
begin
with TFPHTTPClient.Create(nil) do
try
ReadURL:= Post(url,data);
finally
Free;
end;
end;
Any simple code for "example.com", using user:jhondoe and pass:9999 as post data?