Chilkat Examples

ChilkatHOMEAndroid™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi DLLGoJavaNode.jsObjective-CPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwiftTclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex 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
Box
CAdES
CSR
CSV
Cert Store
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
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
Regular Expressions
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
X
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(DataFlex) Example: Http.HttpReq method

Demonstrates how to call the HttpReq method.

Note: This example requires Chilkat v11.0.0 or greater.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoHttp
    Handle hoJson
    Variant vReq
    Handle hoReq
    Variant vResp
    Handle hoResp
    String sTemp1

    Move False To iSuccess

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End
    Move False To iSuccess

    // This example will send an HTTP POST with the body of the HTTP request containing JSON.

    // Create the following JSON: { "name": "Harry", "state": "FL" }

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "name" "Harry" To iSuccess
    Get ComUpdateString Of hoJson "state" "FL" To iSuccess

    // Specify the details of the request
    Get Create (RefClass(cComChilkatHttpRequest)) To hoReq
    If (Not(IsComObjectCreated(hoReq))) Begin
        Send CreateComObject of hoReq
    End

    Set ComHttpVerb Of hoReq To "POST"
    Set ComContentType Of hoReq To "application/json"
    Get ComEmit Of hoJson To sTemp1
    Get ComLoadBodyFromString Of hoReq sTemp1 "utf-8" To iSuccess

    // Send the charset attribute in the HTTP request header.
    Set ComSendCharset Of hoReq To True
    Set ComCharset Of hoReq To "utf-8"

    // Send the POST
    // You can send the POST to the URL below.  
    // The response will contain the raw body of the request that was sent.
    // (i.e. everything except the HTTP request header).

    Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
    If (Not(IsComObjectCreated(hoResp))) Begin
        Send CreateComObject of hoResp
    End
    Get pvComObject of hoReq to vReq
    Get pvComObject of hoResp to vResp
    Get ComHttpReq Of hoHttp "https://www.chilkatsoft.com/echo_request_body.asp" vReq vResp To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Examine the HTTP request header we sent:
    Get ComLastHeader Of hoHttp To sTemp1
    Showln sTemp1

    // The response body contains the raw content of the HTTP request body we sent.
    Get ComBodyStr Of hoResp To sTemp1
    Showln sTemp1

    // Sample output:

    // POST /echo_request_body.asp HTTP/1.1
    // Host: www.chilkatsoft.com
    // Content-Type: application/json; charset=utf-8
    // Content-Length: 29
    // 
    // 
    // {"name":"Harry","state":"FL"}


End_Procedure

 

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