Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

SQL Server Web API Examples

Primary Categories

AWS Translate
Activix CRM
Adyen
Amazon MWS
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Bluzone
CardConnect
ClickBank
Clickatell
Cloudfare
DocuSign
ETrade
Etsy
Facebook
GeoOp
GetHarvest
Jira
MYOB

Magento
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Okta OAuth/OIDC
OneLogin OIDC
PayPal
Peoplevox
Populi
QuickBooks
SOAP finkok.com
Shippo
Shopify
Stripe
SugarCRM
Trello
Twitter
VoiceBase
Vonage
Walmart
Walmart v3
Xero
eBay
effectconnect

 

 

 

(SQL Server) Shippo Create a New Manifest

Demonstrates how to create a manifest for your shipments.

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

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    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
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.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/manifests/
    --     -H "Authorization: ShippoToken shippo_test_831a7a042784f523b95db65444e6e084b636764b" \
    --     -H "Content-Type: application/json"  \
    --     -d '{
    --           "carrier_account": "b741b99f95e841639b54272834bc478c",
    --           "shipment_date": "2014-05-16T23:59:59Z",
    --           "address_from": "28828839a2b04e208ac2aa4945fbca9a",
    --           "transactions": [
    --             "64bba01845ef40d29374032599f22588", 
    --             "c169aa586a844cc49da00d0272b590e1"
    --             ],
    --           "async": false
    --         }'

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

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

    -- {
    --   "carrier_account": "b741b99f95e841639b54272834bc478c",
    --   "shipment_date": "2014-05-16T23:59:59Z",
    --   "address_from": "28828839a2b04e208ac2aa4945fbca9a",
    --   "transactions": [
    --     "64bba01845ef40d29374032599f22588",
    --     "c169aa586a844cc49da00d0272b590e1"
    --   ],
    --   "async": false
    -- }

    DECLARE @json int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @json OUT

    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'carrier_account', 'b741b99f95e841639b54272834bc478c'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'shipment_date', '2014-05-16T23:59:59Z'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'address_from', '28828839a2b04e208ac2aa4945fbca9a'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'transactions[0]', '64bba01845ef40d29374032599f22588'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'transactions[1]', 'c169aa586a844cc49da00d0272b590e1'
    EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'async', 0

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

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, 'https://api.goshippo.com/manifests/', '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
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbResponseBody OUT

    EXEC sp_OAMethod @resp, 'GetBodySb', @success OUT, @sbResponseBody
    DECLARE @jResp int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.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)

    -- {
    --   "address_from": "28828839a2b04e208ac2aa4945fbca9a",
    --   "carrier_account": "b741b99f95e841639b54272834bc478c",
    --   "documents": [
    --     "https://shippo-delivery.s3.amazonaws.com/0fadebf6f60c4aca95fa01bcc59c79ae.pdf?Signature=tlQU3RECwdHUQJQadwqg5bAzGFQ%3D&Expires=1402803835&AWSAccessKeyId=AKIAJTHP3LLFMYAWALIA"
    --   ],
    --   "object_created": "2014-05-16T03:43:52.765Z",
    --   "object_id": "0fadebf6f60c4aca95fa01bcc59c79ae",
    --   "object_owner": "mrhippo@goshippo.com",
    --   "object_updated": "2014-05-16T03:43:55.445Z",
    --   "shipment_date": "2014-05-16T23:59:59Z",
    --   "status": "SUCCESS",
    --   "transactions": [
    --     "64bba01845ef40d29374032599f22588",
    --     "c169aa586a844cc49da00d0272b590e1"
    --   ]
    -- }

    -- 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 @address_from nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @address_from OUT, 'address_from'
    DECLARE @carrier_account nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @carrier_account OUT, 'carrier_account'
    DECLARE @object_created nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @object_created OUT, 'object_created'
    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_updated nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @object_updated OUT, 'object_updated'
    DECLARE @shipment_date nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @shipment_date OUT, 'shipment_date'
    DECLARE @status nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @status OUT, 'status'
    DECLARE @i int
    SELECT @i = 0
    DECLARE @count_i int
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'documents'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'documents[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'transactions'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'transactions[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-2019 Chilkat Software, Inc. All Rights Reserved.