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

Tcl 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

 

 

 

(Tcl) SugarCRM Create a Record

Submit a record to the Sugar instance using the / endpoint. In this example we are going to create an Account record with a Name of 'Test Record' and an email of 'test@sugar.com'.

For more information, see https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.9/Integration/Web_Services/v10/Examples/Bash/How_to_Manipulate_Records_CRUD/#Creating_a_Record

Chilkat Tcl Extension Downloads

Chilkat Tcl Extension Downloads

load ./chilkat.dll

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

set http [new_CkHttp]

# Implements the following CURL command:

# curl -X POST -H OAuth-Token:<access_token> -H Cache-Control:no-cache -d '{ 
#    "name":"Test Record",
#    "email1":"test@sugar.com"
# }' http://<site_url>/rest/v10/Accounts

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

# The following JSON is sent in the request body.

# {
#   "name": "Test Record",
#   "email1": "test@sugar.com"
# }

set json [new_CkJsonObject]

CkJsonObject_UpdateString $json "name" "Test Record"
CkJsonObject_UpdateString $json "email1" "test@sugar.com"

CkHttp_SetRequestHeader $http "Cache-Control" "no-cache"
CkHttp_SetRequestHeader $http "OAuth-Token" "<access_token>"

# resp is a CkHttpResponse
set resp [CkHttp_PostJson3 $http "http://<site_url>/rest/v10/Accounts" "application/json" $json]
if {[CkHttp_get_LastMethodSuccess $http] == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkJsonObject $json
    exit
}

set sbResponseBody [new_CkStringBuilder]

CkHttpResponse_GetBodySb $resp $sbResponseBody
set jResp [new_CkJsonObject]

CkJsonObject_LoadSb $jResp $sbResponseBody
CkJsonObject_put_EmitCompact $jResp 0

puts "Response Body:"
puts [CkJsonObject_emit $jResp]

set respStatusCode [CkHttpResponse_get_StatusCode $resp]
puts "Response Status Code = $respStatusCode"
if {$respStatusCode >= 400} then {
    puts "Response Header:"
    puts [CkHttpResponse_header $resp]
    puts "Failed."
    delete_CkHttpResponse $resp

    delete_CkHttp $http
    delete_CkJsonObject $json
    delete_CkStringBuilder $sbResponseBody
    delete_CkJsonObject $jResp
    exit
}

delete_CkHttpResponse $resp

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

# {
#   "id": "ab2222df-73da-0e92-6887-5705428f4d68",
#   "name": "Test Record",
#   "date_entered": "2016-04-06T13:07:41-04:00",
#   "date_modified": "2016-04-06T13:07:41-04:00",
#   "modified_user_id": "1",
#   "modified_by_name": "Administrator",
#   "modified_user_link": {
#     "full_name": "Administrator",
#     "id": "1",
#     "_acl": {
#       "fields": [
#       ],
#       "delete": "no",
#       "_hash": "8e11bf9be8f04daddee9d08d44ea891e"
#     }
#   },
#   "created_by": "1",
#   "created_by_name": "Administrator",
#   "created_by_link": {
#     "full_name": "Administrator",
#     "id": "1",
#     "_acl": {
#       "fields": [
#       ],
#       "delete": "no",
#       "_hash": "8e11bf9be8f04daddee9d08d44ea891e"
#     }
#   },
#   "description": "",
#   "deleted": false,
#   "facebook": "",
#   "twitter": "",
#   "googleplus": "",
#   "account_type": "",
#   "industry": "",
#   "annual_revenue": "",
#   "phone_fax": "",
#   "billing_address_street": "",
#   "billing_address_street_2": "",
#   "billing_address_street_3": "",
#   "billing_address_street_4": "",
#   "billing_address_city": "",
#   "billing_address_state": "",
#   "billing_address_postalcode": "",
#   "billing_address_country": "",
#   "rating": "",
#   "phone_office": "",
#   "phone_alternate": "",
#   "website": "",
#   "ownership": "",
#   "employees": "",
#   "ticker_symbol": "",
#   "shipping_address_street": "",
#   "shipping_address_street_2": "",
#   "shipping_address_street_3": "",
#   "shipping_address_street_4": "",
#   "shipping_address_city": "",
#   "shipping_address_state": "",
#   "shipping_address_postalcode": "",
#   "shipping_address_country": "",
#   "parent_id": "",
#   "sic_code": "",
#   "duns_num": "",
#   "parent_name": "",
#   "member_of": {
#     "name": "",
#     "id": "",
#     "_acl": {
#       "fields": [
#       ],
#       "_hash": "654d337e0e912edaa00dbb0fb3dc3c17"
#     }
#   },
#   "campaign_id": "",
#   "campaign_name": "",
#   "campaign_accounts": {
#     "name": "",
#     "id": "",
#     "_acl": {
#       "fields": [
#       ],
#       "_hash": "654d337e0e912edaa00dbb0fb3dc3c17"
#     }
#   },
#   "following": true,
#   "my_favorite": false,
#   "tag": [
#   ],
#   "assigned_user_id": "",
#   "assigned_user_name": "",
#   "assigned_user_link": {
#     "full_name": "",
#     "id": "",
#     "_acl": {
#       "fields": [
#       ],
#       "_hash": "654d337e0e912edaa00dbb0fb3dc3c17"
#     }
#   },
#   "team_count": "",
#   "team_count_link": {
#     "team_count": "",
#     "id": "1",
#     "_acl": {
#       "fields": [
#       ],
#       "_hash": "654d337e0e912edaa00dbb0fb3dc3c17"
#     }
#   },
#   "team_name": [
#     {
#       "id": 1,
#       "name": "Global",
#       "name_2": "",
#       "primary": true
#     }
#   ],
#   "email": [
#     {
#       "email_address": "test@sugar.com",
#       "invalid_email": false,
#       "opt_out": false,
#       "primary_address": true,
#       "reply_to_address": false
#     }
#   ],
#   "email1": "test@sugar.com",
#   "email2": "",
#   "invalid_email": false,
#   "email_opt_out": false,
#   "email_addresses_non_primary": "",
#   "_acl": {
#     "fields": {}
#   },
#   "_module": "Accounts"
# }

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

set id [CkJsonObject_stringOf $jResp "id"]
set name [CkJsonObject_stringOf $jResp "name"]
set date_entered [CkJsonObject_stringOf $jResp "date_entered"]
set date_modified [CkJsonObject_stringOf $jResp "date_modified"]
set modified_user_id [CkJsonObject_stringOf $jResp "modified_user_id"]
set modified_by_name [CkJsonObject_stringOf $jResp "modified_by_name"]
set modified_user_linkFull_name [CkJsonObject_stringOf $jResp "modified_user_link.full_name"]
set modified_user_linkId [CkJsonObject_stringOf $jResp "modified_user_link.id"]
set modified_user_link_aclDelete [CkJsonObject_stringOf $jResp "modified_user_link._acl.delete"]
set modified_user_link_acl_hash [CkJsonObject_stringOf $jResp "modified_user_link._acl._hash"]
set created_by [CkJsonObject_stringOf $jResp "created_by"]
set created_by_name [CkJsonObject_stringOf $jResp "created_by_name"]
set created_by_linkFull_name [CkJsonObject_stringOf $jResp "created_by_link.full_name"]
set created_by_linkId [CkJsonObject_stringOf $jResp "created_by_link.id"]
set created_by_link_aclDelete [CkJsonObject_stringOf $jResp "created_by_link._acl.delete"]
set created_by_link_acl_hash [CkJsonObject_stringOf $jResp "created_by_link._acl._hash"]
set description [CkJsonObject_stringOf $jResp "description"]
set deleted [CkJsonObject_BoolOf $jResp "deleted"]
set facebook [CkJsonObject_stringOf $jResp "facebook"]
set twitter [CkJsonObject_stringOf $jResp "twitter"]
set googleplus [CkJsonObject_stringOf $jResp "googleplus"]
set account_type [CkJsonObject_stringOf $jResp "account_type"]
set industry [CkJsonObject_stringOf $jResp "industry"]
set annual_revenue [CkJsonObject_stringOf $jResp "annual_revenue"]
set phone_fax [CkJsonObject_stringOf $jResp "phone_fax"]
set billing_address_street [CkJsonObject_stringOf $jResp "billing_address_street"]
set billing_address_street_2 [CkJsonObject_stringOf $jResp "billing_address_street_2"]
set billing_address_street_3 [CkJsonObject_stringOf $jResp "billing_address_street_3"]
set billing_address_street_4 [CkJsonObject_stringOf $jResp "billing_address_street_4"]
set billing_address_city [CkJsonObject_stringOf $jResp "billing_address_city"]
set billing_address_state [CkJsonObject_stringOf $jResp "billing_address_state"]
set billing_address_postalcode [CkJsonObject_stringOf $jResp "billing_address_postalcode"]
set billing_address_country [CkJsonObject_stringOf $jResp "billing_address_country"]
set rating [CkJsonObject_stringOf $jResp "rating"]
set phone_office [CkJsonObject_stringOf $jResp "phone_office"]
set phone_alternate [CkJsonObject_stringOf $jResp "phone_alternate"]
set website [CkJsonObject_stringOf $jResp "website"]
set ownership [CkJsonObject_stringOf $jResp "ownership"]
set employees [CkJsonObject_stringOf $jResp "employees"]
set ticker_symbol [CkJsonObject_stringOf $jResp "ticker_symbol"]
set shipping_address_street [CkJsonObject_stringOf $jResp "shipping_address_street"]
set shipping_address_street_2 [CkJsonObject_stringOf $jResp "shipping_address_street_2"]
set shipping_address_street_3 [CkJsonObject_stringOf $jResp "shipping_address_street_3"]
set shipping_address_street_4 [CkJsonObject_stringOf $jResp "shipping_address_street_4"]
set shipping_address_city [CkJsonObject_stringOf $jResp "shipping_address_city"]
set shipping_address_state [CkJsonObject_stringOf $jResp "shipping_address_state"]
set shipping_address_postalcode [CkJsonObject_stringOf $jResp "shipping_address_postalcode"]
set shipping_address_country [CkJsonObject_stringOf $jResp "shipping_address_country"]
set parent_id [CkJsonObject_stringOf $jResp "parent_id"]
set sic_code [CkJsonObject_stringOf $jResp "sic_code"]
set duns_num [CkJsonObject_stringOf $jResp "duns_num"]
set parent_name [CkJsonObject_stringOf $jResp "parent_name"]
set member_ofName [CkJsonObject_stringOf $jResp "member_of.name"]
set member_ofId [CkJsonObject_stringOf $jResp "member_of.id"]
set member_of_acl_hash [CkJsonObject_stringOf $jResp "member_of._acl._hash"]
set campaign_id [CkJsonObject_stringOf $jResp "campaign_id"]
set campaign_name [CkJsonObject_stringOf $jResp "campaign_name"]
set campaign_accountsName [CkJsonObject_stringOf $jResp "campaign_accounts.name"]
set campaign_accountsId [CkJsonObject_stringOf $jResp "campaign_accounts.id"]
set campaign_accounts_acl_hash [CkJsonObject_stringOf $jResp "campaign_accounts._acl._hash"]
set following [CkJsonObject_BoolOf $jResp "following"]
set my_favorite [CkJsonObject_BoolOf $jResp "my_favorite"]
set assigned_user_id [CkJsonObject_stringOf $jResp "assigned_user_id"]
set assigned_user_name [CkJsonObject_stringOf $jResp "assigned_user_name"]
set assigned_user_linkFull_name [CkJsonObject_stringOf $jResp "assigned_user_link.full_name"]
set assigned_user_linkId [CkJsonObject_stringOf $jResp "assigned_user_link.id"]
set assigned_user_link_acl_hash [CkJsonObject_stringOf $jResp "assigned_user_link._acl._hash"]
set team_count [CkJsonObject_stringOf $jResp "team_count"]
set team_count_linkTeam_count [CkJsonObject_stringOf $jResp "team_count_link.team_count"]
set team_count_linkId [CkJsonObject_stringOf $jResp "team_count_link.id"]
set team_count_link_acl_hash [CkJsonObject_stringOf $jResp "team_count_link._acl._hash"]
set email1 [CkJsonObject_stringOf $jResp "email1"]
set email2 [CkJsonObject_stringOf $jResp "email2"]
set invalid_email [CkJsonObject_BoolOf $jResp "invalid_email"]
set email_opt_out [CkJsonObject_BoolOf $jResp "email_opt_out"]
set email_addresses_non_primary [CkJsonObject_stringOf $jResp "email_addresses_non_primary"]
set v_module [CkJsonObject_stringOf $jResp "_module"]
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "modified_user_link._acl.fields"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "created_by_link._acl.fields"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "member_of._acl.fields"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "campaign_accounts._acl.fields"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "tag"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "assigned_user_link._acl.fields"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "team_count_link._acl.fields"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "team_name"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set id_int [CkJsonObject_IntOf $jResp "team_name[i].id"]
    set name [CkJsonObject_stringOf $jResp "team_name[i].name"]
    set name_2 [CkJsonObject_stringOf $jResp "team_name[i].name_2"]
    set primary [CkJsonObject_BoolOf $jResp "team_name[i].primary"]
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "email"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set email_address [CkJsonObject_stringOf $jResp "email[i].email_address"]
    set invalid_email [CkJsonObject_BoolOf $jResp "email[i].invalid_email"]
    set opt_out [CkJsonObject_BoolOf $jResp "email[i].opt_out"]
    set primary_address [CkJsonObject_BoolOf $jResp "email[i].primary_address"]
    set reply_to_address [CkJsonObject_BoolOf $jResp "email[i].reply_to_address"]
    set i [expr $i + 1]
}

delete_CkHttp $http
delete_CkJsonObject $json
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $jResp

 

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