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

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

 

 

 

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

ActiveX for 32-bit and 64-bit Windows

LOCAL loHttp
LOCAL lnSuccess
LOCAL loJson
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcId
LOCAL lcName
LOCAL lcDate_entered
LOCAL lcDate_modified
LOCAL lcModified_user_id
LOCAL lcModified_by_name
LOCAL lcModified_user_linkFull_name
LOCAL lcModified_user_linkId
LOCAL lcModified_user_link_aclDelete
LOCAL lcModified_user_link_acl_hash
LOCAL lcCreated_by
LOCAL lcCreated_by_name
LOCAL lcCreated_by_linkFull_name
LOCAL lcCreated_by_linkId
LOCAL lcCreated_by_link_aclDelete
LOCAL lcCreated_by_link_acl_hash
LOCAL lcDescription
LOCAL lnDeleted
LOCAL lcFacebook
LOCAL lcTwitter
LOCAL lcGoogleplus
LOCAL lcAccount_type
LOCAL lcIndustry
LOCAL lcAnnual_revenue
LOCAL lcPhone_fax
LOCAL lcBilling_address_street
LOCAL lcBilling_address_street_2
LOCAL lcBilling_address_street_3
LOCAL lcBilling_address_street_4
LOCAL lcBilling_address_city
LOCAL lcBilling_address_state
LOCAL lcBilling_address_postalcode
LOCAL lcBilling_address_country
LOCAL lcRating
LOCAL lcPhone_office
LOCAL lcPhone_alternate
LOCAL lcWebsite
LOCAL lcOwnership
LOCAL lcEmployees
LOCAL lcTicker_symbol
LOCAL lcShipping_address_street
LOCAL lcShipping_address_street_2
LOCAL lcShipping_address_street_3
LOCAL lcShipping_address_street_4
LOCAL lcShipping_address_city
LOCAL lcShipping_address_state
LOCAL lcShipping_address_postalcode
LOCAL lcShipping_address_country
LOCAL lcParent_id
LOCAL lcSic_code
LOCAL lcDuns_num
LOCAL lcParent_name
LOCAL lcMember_ofName
LOCAL lcMember_ofId
LOCAL lcMember_of_acl_hash
LOCAL lcCampaign_id
LOCAL lcCampaign_name
LOCAL lcCampaign_accountsName
LOCAL lcCampaign_accountsId
LOCAL lcCampaign_accounts_acl_hash
LOCAL lnFollowing
LOCAL lnMy_favorite
LOCAL lcAssigned_user_id
LOCAL lcAssigned_user_name
LOCAL lcAssigned_user_linkFull_name
LOCAL lcAssigned_user_linkId
LOCAL lcAssigned_user_link_acl_hash
LOCAL lcTeam_count
LOCAL lcTeam_count_linkTeam_count
LOCAL lcTeam_count_linkId
LOCAL lcTeam_count_link_acl_hash
LOCAL lcEmail1
LOCAL lcEmail2
LOCAL lnInvalid_email
LOCAL lnEmail_opt_out
LOCAL lcEmail_addresses_non_primary
LOCAL lcV_module
LOCAL i
LOCAL lnCount_i
LOCAL lnId_int
LOCAL lcName_2
LOCAL lnPrimary
LOCAL lcEmail_address
LOCAL lnOpt_out
LOCAL lnPrimary_address
LOCAL lnReply_to_address

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

loHttp = CreateObject('Chilkat_9_5_0.Http')

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

loJson = CreateObject('Chilkat_9_5_0.JsonObject')
loJson.UpdateString("name","Test Record")
loJson.UpdateString("email1","test@sugar.com")

loHttp.SetRequestHeader("Cache-Control","no-cache")
loHttp.SetRequestHeader("OAuth-Token","<access_token>")

loResp = loHttp.PostJson3("http://<site_url>/rest/v10/Accounts","application/json",loJson)
IF (loHttp.LastMethodSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loJson
    CANCEL
ENDIF

loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
loResp.GetBodySb(loSbResponseBody)
loJResp = CreateObject('Chilkat_9_5_0.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
    ? "Response Header:"
    ? loResp.Header
    ? "Failed."
    RELEASE loResp
    RELEASE loHttp
    RELEASE loJson
    RELEASE loSbResponseBody
    RELEASE loJResp
    CANCEL
ENDIF

RELEASE loResp

* 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

lcId = loJResp.StringOf("id")
lcName = loJResp.StringOf("name")
lcDate_entered = loJResp.StringOf("date_entered")
lcDate_modified = loJResp.StringOf("date_modified")
lcModified_user_id = loJResp.StringOf("modified_user_id")
lcModified_by_name = loJResp.StringOf("modified_by_name")
lcModified_user_linkFull_name = loJResp.StringOf("modified_user_link.full_name")
lcModified_user_linkId = loJResp.StringOf("modified_user_link.id")
lcModified_user_link_aclDelete = loJResp.StringOf("modified_user_link._acl.delete")
lcModified_user_link_acl_hash = loJResp.StringOf("modified_user_link._acl._hash")
lcCreated_by = loJResp.StringOf("created_by")
lcCreated_by_name = loJResp.StringOf("created_by_name")
lcCreated_by_linkFull_name = loJResp.StringOf("created_by_link.full_name")
lcCreated_by_linkId = loJResp.StringOf("created_by_link.id")
lcCreated_by_link_aclDelete = loJResp.StringOf("created_by_link._acl.delete")
lcCreated_by_link_acl_hash = loJResp.StringOf("created_by_link._acl._hash")
lcDescription = loJResp.StringOf("description")
lnDeleted = loJResp.BoolOf("deleted")
lcFacebook = loJResp.StringOf("facebook")
lcTwitter = loJResp.StringOf("twitter")
lcGoogleplus = loJResp.StringOf("googleplus")
lcAccount_type = loJResp.StringOf("account_type")
lcIndustry = loJResp.StringOf("industry")
lcAnnual_revenue = loJResp.StringOf("annual_revenue")
lcPhone_fax = loJResp.StringOf("phone_fax")
lcBilling_address_street = loJResp.StringOf("billing_address_street")
lcBilling_address_street_2 = loJResp.StringOf("billing_address_street_2")
lcBilling_address_street_3 = loJResp.StringOf("billing_address_street_3")
lcBilling_address_street_4 = loJResp.StringOf("billing_address_street_4")
lcBilling_address_city = loJResp.StringOf("billing_address_city")
lcBilling_address_state = loJResp.StringOf("billing_address_state")
lcBilling_address_postalcode = loJResp.StringOf("billing_address_postalcode")
lcBilling_address_country = loJResp.StringOf("billing_address_country")
lcRating = loJResp.StringOf("rating")
lcPhone_office = loJResp.StringOf("phone_office")
lcPhone_alternate = loJResp.StringOf("phone_alternate")
lcWebsite = loJResp.StringOf("website")
lcOwnership = loJResp.StringOf("ownership")
lcEmployees = loJResp.StringOf("employees")
lcTicker_symbol = loJResp.StringOf("ticker_symbol")
lcShipping_address_street = loJResp.StringOf("shipping_address_street")
lcShipping_address_street_2 = loJResp.StringOf("shipping_address_street_2")
lcShipping_address_street_3 = loJResp.StringOf("shipping_address_street_3")
lcShipping_address_street_4 = loJResp.StringOf("shipping_address_street_4")
lcShipping_address_city = loJResp.StringOf("shipping_address_city")
lcShipping_address_state = loJResp.StringOf("shipping_address_state")
lcShipping_address_postalcode = loJResp.StringOf("shipping_address_postalcode")
lcShipping_address_country = loJResp.StringOf("shipping_address_country")
lcParent_id = loJResp.StringOf("parent_id")
lcSic_code = loJResp.StringOf("sic_code")
lcDuns_num = loJResp.StringOf("duns_num")
lcParent_name = loJResp.StringOf("parent_name")
lcMember_ofName = loJResp.StringOf("member_of.name")
lcMember_ofId = loJResp.StringOf("member_of.id")
lcMember_of_acl_hash = loJResp.StringOf("member_of._acl._hash")
lcCampaign_id = loJResp.StringOf("campaign_id")
lcCampaign_name = loJResp.StringOf("campaign_name")
lcCampaign_accountsName = loJResp.StringOf("campaign_accounts.name")
lcCampaign_accountsId = loJResp.StringOf("campaign_accounts.id")
lcCampaign_accounts_acl_hash = loJResp.StringOf("campaign_accounts._acl._hash")
lnFollowing = loJResp.BoolOf("following")
lnMy_favorite = loJResp.BoolOf("my_favorite")
lcAssigned_user_id = loJResp.StringOf("assigned_user_id")
lcAssigned_user_name = loJResp.StringOf("assigned_user_name")
lcAssigned_user_linkFull_name = loJResp.StringOf("assigned_user_link.full_name")
lcAssigned_user_linkId = loJResp.StringOf("assigned_user_link.id")
lcAssigned_user_link_acl_hash = loJResp.StringOf("assigned_user_link._acl._hash")
lcTeam_count = loJResp.StringOf("team_count")
lcTeam_count_linkTeam_count = loJResp.StringOf("team_count_link.team_count")
lcTeam_count_linkId = loJResp.StringOf("team_count_link.id")
lcTeam_count_link_acl_hash = loJResp.StringOf("team_count_link._acl._hash")
lcEmail1 = loJResp.StringOf("email1")
lcEmail2 = loJResp.StringOf("email2")
lnInvalid_email = loJResp.BoolOf("invalid_email")
lnEmail_opt_out = loJResp.BoolOf("email_opt_out")
lcEmail_addresses_non_primary = loJResp.StringOf("email_addresses_non_primary")
lcV_module = loJResp.StringOf("_module")
i = 0
lnCount_i = loJResp.SizeOfArray("modified_user_link._acl.fields")
DO WHILE i < lnCount_i
    loJResp.I = i
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("created_by_link._acl.fields")
DO WHILE i < lnCount_i
    loJResp.I = i
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("member_of._acl.fields")
DO WHILE i < lnCount_i
    loJResp.I = i
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("campaign_accounts._acl.fields")
DO WHILE i < lnCount_i
    loJResp.I = i
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("tag")
DO WHILE i < lnCount_i
    loJResp.I = i
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("assigned_user_link._acl.fields")
DO WHILE i < lnCount_i
    loJResp.I = i
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("team_count_link._acl.fields")
DO WHILE i < lnCount_i
    loJResp.I = i
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("team_name")
DO WHILE i < lnCount_i
    loJResp.I = i
    lnId_int = loJResp.IntOf("team_name[i].id")
    lcName = loJResp.StringOf("team_name[i].name")
    lcName_2 = loJResp.StringOf("team_name[i].name_2")
    lnPrimary = loJResp.BoolOf("team_name[i].primary")
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("email")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcEmail_address = loJResp.StringOf("email[i].email_address")
    lnInvalid_email = loJResp.BoolOf("email[i].invalid_email")
    lnOpt_out = loJResp.BoolOf("email[i].opt_out")
    lnPrimary_address = loJResp.BoolOf("email[i].primary_address")
    lnReply_to_address = loJResp.BoolOf("email[i].reply_to_address")
    i = i + 1
ENDDO

RELEASE loHttp
RELEASE loJson
RELEASE loSbResponseBody
RELEASE loJResp


 

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