Hello,
I have tried the trial version for several days by trying several examples. I tried this sparkle with references from the available demo.
procedure TForm1.DoRequest;
var
Req: THttpRequest;
Resp: THttpResponse;
JSONOB : TJSONObject;
JSONVL: TJSONValue;
Info: THttpHeaderInfo;
begin
Resp := nil;
Req := FClient.CreateRequest;
try
// set uri
Req.Uri := 'http:/........';
// set request method
Req.Method := 'POST';
// set content body, if available. Use UTF8 as default encoding,
// we will not worry about this in this simple demo
JSONOB := TJSONObject.Create();
JSONOB.AddPair('id', TJSONNumber.Create(0));
Req.SetContent(TEncoding.UTF8.GetBytes(JSONOB.ToJSON));
Req.Headers.SetValue('content-type', 'application/json');
// perform request
Resp := FClient.Send(Req);
for Info in Resp.Headers.AllHeaders do
begin
memo1.Lines.Add(Info.Name+':'+Info.Value);
end;
JSONVL := TJSONObject.ParseJSONValue(TEncoding.UTF8.GetString(Resp.ContentAsBytes));
try
memo1.Lines.Add(REST.Json.TJson.Format(JSONVL));
finally
JSONVL.Free;
end;
finally
Req.Free;
Resp.Free;
JSONOB.Free;
end;
end;
can it be done using xdataclient, I haven't gotten the reference yet.