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

DataFlex Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(DataFlex) TicketBAI -- Send HTTP POST

See more TicketBAI Examples

Demonstrates how to send a TicketBAI POST and get the response.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vSbXml
    Handle hoSbXml
    Handle hoJson
    String sUrl
    Boolean iBGzip
    Variant vResp
    Handle hoResp
    String sTemp1
    Integer iTemp1
    Boolean bTemp1

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

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

    Get ComSetSslClientCertPfx Of hoHttp "your.pfx" "pfx_password" To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Get the XML we wish to send in the body of the request.
    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbXml
    If (Not(IsComObjectCreated(hoSbXml))) Begin
        Send CreateComObject of hoSbXml
    End
    Get ComLoadFile Of hoSbXml "qa_data/payload.xml" "utf-8" To iSuccess
    If (iSuccess = False) Begin
        Showln "Failed to load XML that is to be the HTTP request body"
        Procedure_Return
    End

    // Build the following JSON

    // { 
    //     "con": "LROE", 
    //     "apa": "1.1", 
    //     "inte": { 
    //         "nif": "número de identificación fiscal", 
    //         "nrs": "nombre o Razón social", 
    //         "ap1": "primer apellido", 
    //         "ap2": "segundo apellido" 
    //     }, 
    //     "drs": { 
    //     "mode": "140/240", 
    //     "ejer": "ejercicio" 
    //     } 
    // }

    // Use this online tool to generate code from sample JSON: 
    // Generate Code to Create JSON

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "con" "LROE" To iSuccess
    Get ComUpdateString Of hoJson "apa" "1.1" To iSuccess
    Get ComUpdateString Of hoJson "inte.nif" "número de identificación fiscal" To iSuccess
    Get ComUpdateString Of hoJson "inte.nrs" "nombre o Razón social" To iSuccess
    Get ComUpdateString Of hoJson "inte.ap1" "primer apellido" To iSuccess
    Get ComUpdateString Of hoJson "inte.ap2" "segundo apellido" To iSuccess
    Get ComUpdateString Of hoJson "drs.mode" "140/240" To iSuccess
    Get ComUpdateString Of hoJson "drs.ejer" "ejercicio" To iSuccess

    // Add required headers...
    Send ComSetRequestHeader To hoHttp "eus-bizkaia-n3-version" "1.0"
    Send ComSetRequestHeader To hoHttp "eus-bizkaia-n3-content-type" "application/xml"
    Get ComEmit Of hoJson To sTemp1
    Send ComSetRequestHeader To hoHttp "eus-bizkaia-n3-data" sTemp1

    Move "https://pruesarrerak.bizkaia.eus/N3B4000M/aurkezpena" To sUrl
    Move True To iBGzip
    Get pvComObject of hoSbXml to vSbXml
    Get ComPTextSb Of hoHttp "POST" sUrl vSbXml "utf-8" "application/octet-stream" False iBGzip To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Send ComClearHeaders To hoHttp

    Get ComStatusCode Of hoResp To iTemp1
    Showln "response status code: " iTemp1

    // Examine the response (it is already decompressed)
    Showln "response body:"
    Get ComBodyStr Of hoResp To sTemp1
    Showln sTemp1

    Send Destroy of hoResp


End_Procedure

 

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