Chilkat Examples

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

Tcl Web API Examples

Primary Categories

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

MercadoLibre
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
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
UniPin
VoiceBase
Vonage
Walmart
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yousign
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Tcl) SugarCRM Updating a Record

Demonstrates how to update a record in the Sugar instance using the //:record endpoint, and the PUT Http method. In this example we update the Account record and change it's name to "Updated Test Record".

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/#Updating_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 PUT -H OAuth-Token:<access_token> -H Cache-Control:no-cache -d '{ 
#    "name":"Updated Record"
# }' http://<site_url>/rest/v10/Accounts/<record_id>

# 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": "Updated Record"
# }

set json [new_CkJsonObject]

CkJsonObject_UpdateString $json "name" "Updated Record"

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

set sbRequestBody [new_CkStringBuilder]

CkJsonObject_EmitSb $json $sbRequestBody

# resp is a CkHttpResponse
set resp [CkHttp_PTextSb $http "PUT" "http://<site_url>/rest/v10/Accounts/<record_id>" $sbRequestBody "utf-8" "application/json" 0 0]
if {[CkHttp_get_LastMethodSuccess $http] == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkJsonObject $json
    delete_CkStringBuilder $sbRequestBody
    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 $sbRequestBody
    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": "Updated Test Record",
#   "date_entered": "2016-04-06T15:03:21-04:00",
#   "date_modified": "2016-04-06T15:03:22-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 $sbRequestBody
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $jResp

 

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