Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Delphi DLL Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(Delphi DLL) Demonstrate the REST FullRequestNoBodySb Method

See more REST Examples

Demonstrates the FullRequestNoBodySb method, which sends an HTTP request with no body and receives the response in a Chilkat StringBuilder object.

Chilkat for Delphi Downloads

Chilkat non-ActiveX DLL for Delphi

Chilkat ActiveX DLL for Delphi

* The examples here use the non-ActiveX DLL.

uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Rest, StringBuilder;

...

procedure TForm1.Button1Click(Sender: TObject);
var
rest: HCkRest;
bTls: Boolean;
port: Integer;
bAutoReconnect: Boolean;
success: Boolean;
sbJson: HCkStringBuilder;

begin
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

rest := CkRest_Create();

// Connect to the REST server.
bTls := True;
port := 443;
bAutoReconnect := True;
success := CkRest_Connect(rest,'chilkatsoft.com',port,bTls,bAutoReconnect);
if (success = False) then
  begin
    Memo1.Lines.Add(CkRest__lastErrorText(rest));
    Exit;
  end;

// Send an HTTP request with no body...

// An HTTP request with no body is a simple HTTP request that is typically a GET or DELETE.
// (POST and PUT requests typically have a request body.)
// The GET method is used to request data from a specified resource, 
// and it does not have a request body. Here's an example of an HTTP GET request:
// 
// GET /api/data HTTP/1.1
// Host: example.com
// Accept: application/json
// 
//  - The HTTP method (also known as the verb) is "GET," indicating that the client wants to retrieve data from the specified resource.
//  - The request path is "/api/data," representing the resource the client wants to access.
//  - The "Host" header specifies the hostname of the server being requested.  Chilkat automatically adds it.
//  - The "Accept" header indicates the media type (MIME type) that the client can understand and would like to receive in the response. In this case, it specifies that the client prefers to receive data in JSON format.
// 
// Since the GET method does not have a request body, the request ends after the headers. 
// The server will process the request, retrieve the requested data (if available), and respond with an HTTP response 
// containing the requested data (if any) in the message body.
// 
// The body of the HTTP response is written to the StringBuilder object (overwriting whatever content the StringBuilder may have already contained).
// 

CkRest_AddHeader(rest,'Accept','application/json');

sbJson := CkStringBuilder_Create();
success := CkRest_FullRequestNoBodySb(rest,'GET','/testData/helloWorld.json',sbJson);
if (success = False) then
  begin
    Memo1.Lines.Add(CkRest__lastErrorText(rest));
    Exit;
  end;

Memo1.Lines.Add('Response status code = ' + IntToStr(CkRest_getResponseStatusCode(rest)));
Memo1.Lines.Add('Response body:');
Memo1.Lines.Add(CkStringBuilder__getAsString(sbJson));

CkRest_Dispose(rest);
CkStringBuilder_Dispose(sbJson);

end;

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.