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

Swift 3,4,5... 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
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

 

 

 

(Swift 3,4,5...) 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 Downloads for the Swift Programming Language

MAC OS X (Cocoa) Objective-C/Swift Libs

iOS Objective-C/Swift Libs

func chilkatTest() {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    let http = CkoHttp()!
    var success: Bool

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

    let json = CkoJsonObject()!
    json.update("name", value: "Updated Record")

    http.setRequestHeader("Cache-Control", value: "no-cache")
    http.setRequestHeader("OAuth-Token", value: "<access_token>")

    let sbRequestBody = CkoStringBuilder()!
    json.emitSb(sbRequestBody)

    var resp: CkoHttpResponse? = http.pTextSb("PUT", url: "http://<site_url>/rest/v10/Accounts/<record_id>", textData: sbRequestBody, charset: "utf-8", contentType: "application/json", md5: false, gzip: false)
    if http.lastMethodSuccess == false {
        print("\(http.lastErrorText!)")
        return
    }

    let sbResponseBody = CkoStringBuilder()!
    resp!.getBodySb(sbResponseBody)
    let jResp = CkoJsonObject()!
    jResp.loadSb(sbResponseBody)
    jResp.emitCompact = false

    print("Response Body:")
    print("\(jResp.emit()!)")

    var respStatusCode: Int = resp!.statusCode.intValue
    print("Response Status Code = \(respStatusCode)")
    if respStatusCode >= 400 {
        print("Response Header:")
        print("\(resp!.header!)")
        print("Failed.")
        resp = nil
        return
    }

    resp = nil

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

    var id: String?
    var name: String?
    var date_entered: String?
    var date_modified: String?
    var modified_user_id: String?
    var modified_by_name: String?
    var modified_user_linkFull_name: String?
    var modified_user_linkId: String?
    var modified_user_link_aclDelete: String?
    var modified_user_link_acl_hash: String?
    var created_by: String?
    var created_by_name: String?
    var created_by_linkFull_name: String?
    var created_by_linkId: String?
    var created_by_link_aclDelete: String?
    var created_by_link_acl_hash: String?
    var description: String?
    var deleted: Bool
    var facebook: String?
    var twitter: String?
    var googleplus: String?
    var account_type: String?
    var industry: String?
    var annual_revenue: String?
    var phone_fax: String?
    var billing_address_street: String?
    var billing_address_street_2: String?
    var billing_address_street_3: String?
    var billing_address_street_4: String?
    var billing_address_city: String?
    var billing_address_state: String?
    var billing_address_postalcode: String?
    var billing_address_country: String?
    var rating: String?
    var phone_office: String?
    var phone_alternate: String?
    var website: String?
    var ownership: String?
    var employees: String?
    var ticker_symbol: String?
    var shipping_address_street: String?
    var shipping_address_street_2: String?
    var shipping_address_street_3: String?
    var shipping_address_street_4: String?
    var shipping_address_city: String?
    var shipping_address_state: String?
    var shipping_address_postalcode: String?
    var shipping_address_country: String?
    var parent_id: String?
    var sic_code: String?
    var duns_num: String?
    var parent_name: String?
    var member_ofName: String?
    var member_ofId: String?
    var member_of_acl_hash: String?
    var campaign_id: String?
    var campaign_name: String?
    var campaign_accountsName: String?
    var campaign_accountsId: String?
    var campaign_accounts_acl_hash: String?
    var following: Bool
    var my_favorite: Bool
    var assigned_user_id: String?
    var assigned_user_name: String?
    var assigned_user_linkFull_name: String?
    var assigned_user_linkId: String?
    var assigned_user_link_acl_hash: String?
    var team_count: String?
    var team_count_linkTeam_count: String?
    var team_count_linkId: String?
    var team_count_link_acl_hash: String?
    var email1: String?
    var email2: String?
    var invalid_email: Bool
    var email_opt_out: Bool
    var email_addresses_non_primary: String?
    var v_module: String?
    var i: Int
    var count_i: Int
    var id_int: Int
    var name_2: String?
    var primary: Bool
    var email_address: String?
    var opt_out: Bool
    var primary_address: Bool
    var reply_to_address: Bool

    id = jResp.string(of: "id")
    name = jResp.string(of: "name")
    date_entered = jResp.string(of: "date_entered")
    date_modified = jResp.string(of: "date_modified")
    modified_user_id = jResp.string(of: "modified_user_id")
    modified_by_name = jResp.string(of: "modified_by_name")
    modified_user_linkFull_name = jResp.string(of: "modified_user_link.full_name")
    modified_user_linkId = jResp.string(of: "modified_user_link.id")
    modified_user_link_aclDelete = jResp.string(of: "modified_user_link._acl.delete")
    modified_user_link_acl_hash = jResp.string(of: "modified_user_link._acl._hash")
    created_by = jResp.string(of: "created_by")
    created_by_name = jResp.string(of: "created_by_name")
    created_by_linkFull_name = jResp.string(of: "created_by_link.full_name")
    created_by_linkId = jResp.string(of: "created_by_link.id")
    created_by_link_aclDelete = jResp.string(of: "created_by_link._acl.delete")
    created_by_link_acl_hash = jResp.string(of: "created_by_link._acl._hash")
    description = jResp.string(of: "description")
    deleted = jResp.bool(of: "deleted")
    facebook = jResp.string(of: "facebook")
    twitter = jResp.string(of: "twitter")
    googleplus = jResp.string(of: "googleplus")
    account_type = jResp.string(of: "account_type")
    industry = jResp.string(of: "industry")
    annual_revenue = jResp.string(of: "annual_revenue")
    phone_fax = jResp.string(of: "phone_fax")
    billing_address_street = jResp.string(of: "billing_address_street")
    billing_address_street_2 = jResp.string(of: "billing_address_street_2")
    billing_address_street_3 = jResp.string(of: "billing_address_street_3")
    billing_address_street_4 = jResp.string(of: "billing_address_street_4")
    billing_address_city = jResp.string(of: "billing_address_city")
    billing_address_state = jResp.string(of: "billing_address_state")
    billing_address_postalcode = jResp.string(of: "billing_address_postalcode")
    billing_address_country = jResp.string(of: "billing_address_country")
    rating = jResp.string(of: "rating")
    phone_office = jResp.string(of: "phone_office")
    phone_alternate = jResp.string(of: "phone_alternate")
    website = jResp.string(of: "website")
    ownership = jResp.string(of: "ownership")
    employees = jResp.string(of: "employees")
    ticker_symbol = jResp.string(of: "ticker_symbol")
    shipping_address_street = jResp.string(of: "shipping_address_street")
    shipping_address_street_2 = jResp.string(of: "shipping_address_street_2")
    shipping_address_street_3 = jResp.string(of: "shipping_address_street_3")
    shipping_address_street_4 = jResp.string(of: "shipping_address_street_4")
    shipping_address_city = jResp.string(of: "shipping_address_city")
    shipping_address_state = jResp.string(of: "shipping_address_state")
    shipping_address_postalcode = jResp.string(of: "shipping_address_postalcode")
    shipping_address_country = jResp.string(of: "shipping_address_country")
    parent_id = jResp.string(of: "parent_id")
    sic_code = jResp.string(of: "sic_code")
    duns_num = jResp.string(of: "duns_num")
    parent_name = jResp.string(of: "parent_name")
    member_ofName = jResp.string(of: "member_of.name")
    member_ofId = jResp.string(of: "member_of.id")
    member_of_acl_hash = jResp.string(of: "member_of._acl._hash")
    campaign_id = jResp.string(of: "campaign_id")
    campaign_name = jResp.string(of: "campaign_name")
    campaign_accountsName = jResp.string(of: "campaign_accounts.name")
    campaign_accountsId = jResp.string(of: "campaign_accounts.id")
    campaign_accounts_acl_hash = jResp.string(of: "campaign_accounts._acl._hash")
    following = jResp.bool(of: "following")
    my_favorite = jResp.bool(of: "my_favorite")
    assigned_user_id = jResp.string(of: "assigned_user_id")
    assigned_user_name = jResp.string(of: "assigned_user_name")
    assigned_user_linkFull_name = jResp.string(of: "assigned_user_link.full_name")
    assigned_user_linkId = jResp.string(of: "assigned_user_link.id")
    assigned_user_link_acl_hash = jResp.string(of: "assigned_user_link._acl._hash")
    team_count = jResp.string(of: "team_count")
    team_count_linkTeam_count = jResp.string(of: "team_count_link.team_count")
    team_count_linkId = jResp.string(of: "team_count_link.id")
    team_count_link_acl_hash = jResp.string(of: "team_count_link._acl._hash")
    email1 = jResp.string(of: "email1")
    email2 = jResp.string(of: "email2")
    invalid_email = jResp.bool(of: "invalid_email")
    email_opt_out = jResp.bool(of: "email_opt_out")
    email_addresses_non_primary = jResp.string(of: "email_addresses_non_primary")
    v_module = jResp.string(of: "_module")
    i = 0
    count_i = jResp.size(ofArray: "modified_user_link._acl.fields").intValue
    while i < count_i {
        jResp.i = i
        i = i + 1
    }

    i = 0
    count_i = jResp.size(ofArray: "created_by_link._acl.fields").intValue
    while i < count_i {
        jResp.i = i
        i = i + 1
    }

    i = 0
    count_i = jResp.size(ofArray: "member_of._acl.fields").intValue
    while i < count_i {
        jResp.i = i
        i = i + 1
    }

    i = 0
    count_i = jResp.size(ofArray: "campaign_accounts._acl.fields").intValue
    while i < count_i {
        jResp.i = i
        i = i + 1
    }

    i = 0
    count_i = jResp.size(ofArray: "tag").intValue
    while i < count_i {
        jResp.i = i
        i = i + 1
    }

    i = 0
    count_i = jResp.size(ofArray: "assigned_user_link._acl.fields").intValue
    while i < count_i {
        jResp.i = i
        i = i + 1
    }

    i = 0
    count_i = jResp.size(ofArray: "team_count_link._acl.fields").intValue
    while i < count_i {
        jResp.i = i
        i = i + 1
    }

    i = 0
    count_i = jResp.size(ofArray: "team_name").intValue
    while i < count_i {
        jResp.i = i
        id_int = jResp.int(of: "team_name[i].id").intValue
        name = jResp.string(of: "team_name[i].name")
        name_2 = jResp.string(of: "team_name[i].name_2")
        primary = jResp.bool(of: "team_name[i].primary")
        i = i + 1
    }

    i = 0
    count_i = jResp.size(ofArray: "email").intValue
    while i < count_i {
        jResp.i = i
        email_address = jResp.string(of: "email[i].email_address")
        invalid_email = jResp.bool(of: "email[i].invalid_email")
        opt_out = jResp.bool(of: "email[i].opt_out")
        primary_address = jResp.bool(of: "email[i].primary_address")
        reply_to_address = jResp.bool(of: "email[i].reply_to_address")
        i = i + 1
    }


}

 

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