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

SQL Server 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
JCC Cyprus
Jira
Lightspeed
MYOB
Magento
Mailgun
Malaysia MyInvois

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
Salesforce
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
TikTok Shop
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

 

 

 

(SQL Server) Shippo Create Customs Declaration

Demonstrates how to create a customs declaration and send a POST request with the necessary information to the Customs Declarations endpoint.

For more information, see https://goshippo.com/docs/international/

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    -- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    -- Implements the following CURL command:

    -- curl https://api.goshippo.com/customs/declarations/ \
    --     -H "Authorization: ShippoToken <API_TOKEN>" \
    --     -H "Content-Type: application/json"  \
    --     -d '{          
    --           "contents_type": "MERCHANDISE",
    --           "non_delivery_option": "RETURN",
    --           "certify": true,
    --           "certify_signer": "Simon Kreuz",
    --           "incoterm": "DDU",
    --           "items": [{
    --                     "description": "T-shirt",
    --                     "quantity": 20,
    --                     "net_weight": "5",
    --                     "mass_unit": "lb",
    --                     "value_amount": "200",
    --                     "value_currency": "USD",
    --                     "tariff_number": "",
    --                     "origin_country": "US"
    --             }]
    --     }'

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

    -- The following JSON is sent in the request body.

    -- {
    --   "contents_type": "MERCHANDISE",
    --   "non_delivery_option": "RETURN",
    --   "certify": true,
    --   "certify_signer": "Simon Kreuz",
    --   "incoterm": "DDU",
    --   "items": [
    --     {
    --       "description": "T-shirt",
    --       "quantity": 20,
    --       "net_weight": "5",
    --       "mass_unit": "lb",
    --       "value_amount": "200",
    --       "value_currency": "USD",
    --       "tariff_number": "",
    --       "origin_country": "US"
    --     }
    --   ]
    -- }

    DECLARE @json int
    -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT

    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'contents_type', 'MERCHANDISE'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'non_delivery_option', 'RETURN'
    EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'certify', 1
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'certify_signer', 'Simon Kreuz'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'incoterm', 'DDU'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].description', 'T-shirt'
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'items[0].quantity', 20
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].net_weight', '5'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].mass_unit', 'lb'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].value_amount', '200'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].value_currency', 'USD'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].tariff_number', ''
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].origin_country', 'US'

    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Authorization', 'ShippoToken <API_TOKEN>'
    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'application/json'

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, 'https://api.goshippo.com/customs/declarations/', 'application/json', @json
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @json
        RETURN
      END

    DECLARE @sbResponseBody int
    -- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT

    EXEC sp_OAMethod @resp, 'GetBodySb', @success OUT, @sbResponseBody
    DECLARE @jResp int
    -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT

    EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
    EXEC sp_OASetProperty @jResp, 'EmitCompact', 0


    PRINT 'Response Body:'
    EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
    PRINT @sTmp0

    DECLARE @respStatusCode int
    EXEC sp_OAGetProperty @resp, 'StatusCode', @respStatusCode OUT

    PRINT 'Response Status Code = ' + @respStatusCode
    IF @respStatusCode >= 400
      BEGIN

        PRINT 'Response Header:'
        EXEC sp_OAGetProperty @resp, 'Header', @sTmp0 OUT
        PRINT @sTmp0

        PRINT 'Failed.'
        EXEC @hr = sp_OADestroy @resp

        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @json
        EXEC @hr = sp_OADestroy @sbResponseBody
        EXEC @hr = sp_OADestroy @jResp
        RETURN
      END
    EXEC @hr = sp_OADestroy @resp

    -- Sample JSON response:
    -- (Sample code for parsing the JSON response is shown below)

    -- {
    --   "object_created": "2019-07-04T16:00:29.043Z",
    --   "object_updated": "2019-07-04T16:00:29.043Z",
    --   "object_id": "4a1e6ab7b1ba49ed9bc6cb1a8798e0fd",
    --   "object_owner": "admin@chilkatsoft.com",
    --   "object_state": "VALID",
    --   "address_importer": null,
    --   "certify_signer": "Simon Kreuz",
    --   "certify": true,
    --   "items": [
    --     "4096c68693364b7ea0af72fb869ee861"
    --   ],
    --   "non_delivery_option": "RETURN",
    --   "contents_type": "MERCHANDISE",
    --   "contents_explanation": "",
    --   "exporter_reference": "",
    --   "importer_reference": "",
    --   "invoice": "",
    --   "commercial_invoice": false,
    --   "license": "",
    --   "certificate": "",
    --   "notes": "",
    --   "eel_pfc": "",
    --   "aes_itn": "",
    --   "disclaimer": "",
    --   "incoterm": "DDU",
    --   "metadata": "",
    --   "test": true,
    --   "duties_payor": null
    -- }

    -- Sample code for parsing the JSON response...
    -- Use the following online tool to generate parsing code from sample JSON:
    -- Generate Parsing Code from JSON

    DECLARE @strVal nvarchar(4000)

    DECLARE @object_created nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @object_created OUT, 'object_created'
    DECLARE @object_updated nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @object_updated OUT, 'object_updated'
    DECLARE @object_id nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @object_id OUT, 'object_id'
    DECLARE @object_owner nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @object_owner OUT, 'object_owner'
    DECLARE @object_state nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @object_state OUT, 'object_state'
    DECLARE @address_importer nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @address_importer OUT, 'address_importer'
    DECLARE @certify_signer nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @certify_signer OUT, 'certify_signer'
    DECLARE @certify int
    EXEC sp_OAMethod @jResp, 'BoolOf', @certify OUT, 'certify'
    DECLARE @non_delivery_option nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @non_delivery_option OUT, 'non_delivery_option'
    DECLARE @contents_type nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @contents_type OUT, 'contents_type'
    DECLARE @contents_explanation nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @contents_explanation OUT, 'contents_explanation'
    DECLARE @exporter_reference nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @exporter_reference OUT, 'exporter_reference'
    DECLARE @importer_reference nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @importer_reference OUT, 'importer_reference'
    DECLARE @invoice nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @invoice OUT, 'invoice'
    DECLARE @commercial_invoice int
    EXEC sp_OAMethod @jResp, 'BoolOf', @commercial_invoice OUT, 'commercial_invoice'
    DECLARE @license nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @license OUT, 'license'
    DECLARE @certificate nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @certificate OUT, 'certificate'
    DECLARE @notes nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @notes OUT, 'notes'
    DECLARE @eel_pfc nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @eel_pfc OUT, 'eel_pfc'
    DECLARE @aes_itn nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @aes_itn OUT, 'aes_itn'
    DECLARE @disclaimer nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @disclaimer OUT, 'disclaimer'
    DECLARE @incoterm nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @incoterm OUT, 'incoterm'
    DECLARE @metadata nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @metadata OUT, 'metadata'
    DECLARE @test int
    EXEC sp_OAMethod @jResp, 'BoolOf', @test OUT, 'test'
    DECLARE @duties_payor nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @duties_payor OUT, 'duties_payor'
    DECLARE @i int
    SELECT @i = 0
    DECLARE @count_i int
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'items'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'items[i]'
        SELECT @i = @i + 1
      END

    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @json
    EXEC @hr = sp_OADestroy @sbResponseBody
    EXEC @hr = sp_OADestroy @jResp


END
GO

 

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