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
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

 

 

 

(DataFlex) 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 ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Handle hoJson
    Variant vSbRequestBody
    Handle hoSbRequestBody
    Variant vResp
    Handle hoResp
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sId
    String sName
    String sDate_entered
    String sDate_modified
    String sModified_user_id
    String sModified_by_name
    String sModified_user_linkFull_name
    String sModified_user_linkId
    String sModified_user_link_aclDelete
    String sModified_user_link_acl_hash
    String sCreated_by
    String sCreated_by_name
    String sCreated_by_linkFull_name
    String sCreated_by_linkId
    String sCreated_by_link_aclDelete
    String sCreated_by_link_acl_hash
    String sDescription
    Boolean iDeleted
    String sFacebook
    String sTwitter
    String sGoogleplus
    String sAccount_type
    String sIndustry
    String sAnnual_revenue
    String sPhone_fax
    String sBilling_address_street
    String sBilling_address_street_2
    String sBilling_address_street_3
    String sBilling_address_street_4
    String sBilling_address_city
    String sBilling_address_state
    String sBilling_address_postalcode
    String sBilling_address_country
    String sRating
    String sPhone_office
    String sPhone_alternate
    String sWebsite
    String sOwnership
    String sEmployees
    String sTicker_symbol
    String sShipping_address_street
    String sShipping_address_street_2
    String sShipping_address_street_3
    String sShipping_address_street_4
    String sShipping_address_city
    String sShipping_address_state
    String sShipping_address_postalcode
    String sShipping_address_country
    String sParent_id
    String sSic_code
    String sDuns_num
    String sParent_name
    String sMember_ofName
    String sMember_ofId
    String sMember_of_acl_hash
    String sCampaign_id
    String sCampaign_name
    String sCampaign_accountsName
    String sCampaign_accountsId
    String sCampaign_accounts_acl_hash
    Boolean iFollowing
    Boolean iMy_favorite
    String sAssigned_user_id
    String sAssigned_user_name
    String sAssigned_user_linkFull_name
    String sAssigned_user_linkId
    String sAssigned_user_link_acl_hash
    String sTeam_count
    String sTeam_count_linkTeam_count
    String sTeam_count_linkId
    String sTeam_count_link_acl_hash
    String sEmail1
    String sEmail2
    Boolean iInvalid_email
    Boolean iEmail_opt_out
    String sEmail_addresses_non_primary
    String sV_module
    Integer i
    Integer iCount_i
    Integer iId_int
    String sName_2
    Boolean iPrimary
    String sEmail_address
    Boolean iOpt_out
    Boolean iPrimary_address
    Boolean iReply_to_address
    String sTemp1
    Boolean bTemp1

    // This example assumes 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

    // 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"
    // }

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "name" "Updated Record" To iSuccess

    Send ComSetRequestHeader To hoHttp "Cache-Control" "no-cache"
    Send ComSetRequestHeader To hoHttp "OAuth-Token" "<access_token>"

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbRequestBody
    If (Not(IsComObjectCreated(hoSbRequestBody))) Begin
        Send CreateComObject of hoSbRequestBody
    End
    Get pvComObject of hoSbRequestBody to vSbRequestBody
    Get ComEmitSb Of hoJson vSbRequestBody To iSuccess

    Get pvComObject of hoSbRequestBody to vSbRequestBody
    Get ComPTextSb Of hoHttp "PUT" "http://<site_url>/rest/v10/Accounts/<record_id>" vSbRequestBody "utf-8" "application/json" False False 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

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess
    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJResp To sTemp1
    Showln sTemp1

    Get ComStatusCode Of hoResp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComHeader Of hoResp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Send Destroy of hoResp
        Procedure_Return
    End

    Send Destroy of hoResp

    // 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

    Get ComStringOf Of hoJResp "id" To sId
    Get ComStringOf Of hoJResp "name" To sName
    Get ComStringOf Of hoJResp "date_entered" To sDate_entered
    Get ComStringOf Of hoJResp "date_modified" To sDate_modified
    Get ComStringOf Of hoJResp "modified_user_id" To sModified_user_id
    Get ComStringOf Of hoJResp "modified_by_name" To sModified_by_name
    Get ComStringOf Of hoJResp "modified_user_link.full_name" To sModified_user_linkFull_name
    Get ComStringOf Of hoJResp "modified_user_link.id" To sModified_user_linkId
    Get ComStringOf Of hoJResp "modified_user_link._acl.delete" To sModified_user_link_aclDelete
    Get ComStringOf Of hoJResp "modified_user_link._acl._hash" To sModified_user_link_acl_hash
    Get ComStringOf Of hoJResp "created_by" To sCreated_by
    Get ComStringOf Of hoJResp "created_by_name" To sCreated_by_name
    Get ComStringOf Of hoJResp "created_by_link.full_name" To sCreated_by_linkFull_name
    Get ComStringOf Of hoJResp "created_by_link.id" To sCreated_by_linkId
    Get ComStringOf Of hoJResp "created_by_link._acl.delete" To sCreated_by_link_aclDelete
    Get ComStringOf Of hoJResp "created_by_link._acl._hash" To sCreated_by_link_acl_hash
    Get ComStringOf Of hoJResp "description" To sDescription
    Get ComBoolOf Of hoJResp "deleted" To iDeleted
    Get ComStringOf Of hoJResp "facebook" To sFacebook
    Get ComStringOf Of hoJResp "twitter" To sTwitter
    Get ComStringOf Of hoJResp "googleplus" To sGoogleplus
    Get ComStringOf Of hoJResp "account_type" To sAccount_type
    Get ComStringOf Of hoJResp "industry" To sIndustry
    Get ComStringOf Of hoJResp "annual_revenue" To sAnnual_revenue
    Get ComStringOf Of hoJResp "phone_fax" To sPhone_fax
    Get ComStringOf Of hoJResp "billing_address_street" To sBilling_address_street
    Get ComStringOf Of hoJResp "billing_address_street_2" To sBilling_address_street_2
    Get ComStringOf Of hoJResp "billing_address_street_3" To sBilling_address_street_3
    Get ComStringOf Of hoJResp "billing_address_street_4" To sBilling_address_street_4
    Get ComStringOf Of hoJResp "billing_address_city" To sBilling_address_city
    Get ComStringOf Of hoJResp "billing_address_state" To sBilling_address_state
    Get ComStringOf Of hoJResp "billing_address_postalcode" To sBilling_address_postalcode
    Get ComStringOf Of hoJResp "billing_address_country" To sBilling_address_country
    Get ComStringOf Of hoJResp "rating" To sRating
    Get ComStringOf Of hoJResp "phone_office" To sPhone_office
    Get ComStringOf Of hoJResp "phone_alternate" To sPhone_alternate
    Get ComStringOf Of hoJResp "website" To sWebsite
    Get ComStringOf Of hoJResp "ownership" To sOwnership
    Get ComStringOf Of hoJResp "employees" To sEmployees
    Get ComStringOf Of hoJResp "ticker_symbol" To sTicker_symbol
    Get ComStringOf Of hoJResp "shipping_address_street" To sShipping_address_street
    Get ComStringOf Of hoJResp "shipping_address_street_2" To sShipping_address_street_2
    Get ComStringOf Of hoJResp "shipping_address_street_3" To sShipping_address_street_3
    Get ComStringOf Of hoJResp "shipping_address_street_4" To sShipping_address_street_4
    Get ComStringOf Of hoJResp "shipping_address_city" To sShipping_address_city
    Get ComStringOf Of hoJResp "shipping_address_state" To sShipping_address_state
    Get ComStringOf Of hoJResp "shipping_address_postalcode" To sShipping_address_postalcode
    Get ComStringOf Of hoJResp "shipping_address_country" To sShipping_address_country
    Get ComStringOf Of hoJResp "parent_id" To sParent_id
    Get ComStringOf Of hoJResp "sic_code" To sSic_code
    Get ComStringOf Of hoJResp "duns_num" To sDuns_num
    Get ComStringOf Of hoJResp "parent_name" To sParent_name
    Get ComStringOf Of hoJResp "member_of.name" To sMember_ofName
    Get ComStringOf Of hoJResp "member_of.id" To sMember_ofId
    Get ComStringOf Of hoJResp "member_of._acl._hash" To sMember_of_acl_hash
    Get ComStringOf Of hoJResp "campaign_id" To sCampaign_id
    Get ComStringOf Of hoJResp "campaign_name" To sCampaign_name
    Get ComStringOf Of hoJResp "campaign_accounts.name" To sCampaign_accountsName
    Get ComStringOf Of hoJResp "campaign_accounts.id" To sCampaign_accountsId
    Get ComStringOf Of hoJResp "campaign_accounts._acl._hash" To sCampaign_accounts_acl_hash
    Get ComBoolOf Of hoJResp "following" To iFollowing
    Get ComBoolOf Of hoJResp "my_favorite" To iMy_favorite
    Get ComStringOf Of hoJResp "assigned_user_id" To sAssigned_user_id
    Get ComStringOf Of hoJResp "assigned_user_name" To sAssigned_user_name
    Get ComStringOf Of hoJResp "assigned_user_link.full_name" To sAssigned_user_linkFull_name
    Get ComStringOf Of hoJResp "assigned_user_link.id" To sAssigned_user_linkId
    Get ComStringOf Of hoJResp "assigned_user_link._acl._hash" To sAssigned_user_link_acl_hash
    Get ComStringOf Of hoJResp "team_count" To sTeam_count
    Get ComStringOf Of hoJResp "team_count_link.team_count" To sTeam_count_linkTeam_count
    Get ComStringOf Of hoJResp "team_count_link.id" To sTeam_count_linkId
    Get ComStringOf Of hoJResp "team_count_link._acl._hash" To sTeam_count_link_acl_hash
    Get ComStringOf Of hoJResp "email1" To sEmail1
    Get ComStringOf Of hoJResp "email2" To sEmail2
    Get ComBoolOf Of hoJResp "invalid_email" To iInvalid_email
    Get ComBoolOf Of hoJResp "email_opt_out" To iEmail_opt_out
    Get ComStringOf Of hoJResp "email_addresses_non_primary" To sEmail_addresses_non_primary
    Get ComStringOf Of hoJResp "_module" To sV_module
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "modified_user_link._acl.fields" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "created_by_link._acl.fields" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "member_of._acl.fields" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "campaign_accounts._acl.fields" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "tag" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "assigned_user_link._acl.fields" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "team_count_link._acl.fields" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "team_name" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComIntOf Of hoJResp "team_name[i].id" To iId_int
        Get ComStringOf Of hoJResp "team_name[i].name" To sName
        Get ComStringOf Of hoJResp "team_name[i].name_2" To sName_2
        Get ComBoolOf Of hoJResp "team_name[i].primary" To iPrimary
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "email" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "email[i].email_address" To sEmail_address
        Get ComBoolOf Of hoJResp "email[i].invalid_email" To iInvalid_email
        Get ComBoolOf Of hoJResp "email[i].opt_out" To iOpt_out
        Get ComBoolOf Of hoJResp "email[i].primary_address" To iPrimary_address
        Get ComBoolOf Of hoJResp "email[i].reply_to_address" To iReply_to_address
        Move (i + 1) To i
    Loop



End_Procedure

 

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