Delphi DLL
Delphi DLL
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 DLL Downloads
var
success: Boolean;
rest: HCkRest;
bTls: Boolean;
bAutoReconnect: Boolean;
sbResponse: HCkStringBuilder;
responseText: PWideChar;
begin
success := False;
rest := CkRest_Create();
bTls := True;
bAutoReconnect := True;
success := CkRest_Connect(rest,'example.com',443,bTls,bAutoReconnect);
if (success = False) then
begin
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
// FullRequestNoBodySb sends a request with no body and stores the text response body in a
// StringBuilder.
sbResponse := CkStringBuilder_Create();
success := CkRest_FullRequestNoBodySb(rest,'GET','/api/items/123',sbResponse);
if (success = False) then
begin
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
responseText := CkStringBuilder__getAsString(sbResponse);
if (CkStringBuilder_getLastMethodSuccess(sbResponse) = False) then
begin
Memo1.Lines.Add(CkStringBuilder__lastErrorText(sbResponse));
Exit;
end;
Memo1.Lines.Add(responseText);
CkRest_Dispose(rest);
CkStringBuilder_Dispose(sbResponse);