Delphi ActiveX
Delphi ActiveX
Send a Bodyless REST Request into a StringBuilder
See more REST Examples
Demonstrates Rest.FullRequestNoBodySb, which sends a request with no body and stores the text response body in a StringBuilder.
Background. This variant of the no-body full request writes the response into a StringBuilder rather than returning it as a string, which is convenient when the response will be further processed in place.
Chilkat Delphi ActiveX Downloads
var
success: Integer;
rest: TChilkatRest;
bTls: Integer;
bAutoReconnect: Integer;
sbResponse: TChilkatStringBuilder;
responseText: WideString;
begin
success := 0;
rest := TChilkatRest.Create(Self);
bTls := 1;
bAutoReconnect := 1;
success := rest.Connect('example.com',443,bTls,bAutoReconnect);
if (success = 0) then
begin
Memo1.Lines.Add(rest.LastErrorText);
Exit;
end;
// FullRequestNoBodySb sends a request with no body and stores the text response body in a
// StringBuilder.
sbResponse := TChilkatStringBuilder.Create(Self);
success := rest.FullRequestNoBodySb('GET','/api/items/123',sbResponse.ControlInterface);
if (success = 0) then
begin
Memo1.Lines.Add(rest.LastErrorText);
Exit;
end;
responseText := sbResponse.GetAsString();
if (sbResponse.LastMethodSuccess = 0) then
begin
Memo1.Lines.Add(sbResponse.LastErrorText);
Exit;
end;
Memo1.Lines.Add(responseText);