Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Lianja) SugarCRM Create a RecordSubmit a record to the Sugar instance using the / 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
// This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loHttp = createobject("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" // } loJson = createobject("CkJsonObject") 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 = .F.) then ? loHttp.LastErrorText release loHttp release loJson return endif loSbResponseBody = createobject("CkStringBuilder") loResp.GetBodySb(loSbResponseBody) loJResp = createobject("CkJsonObject") loJResp.LoadSb(loSbResponseBody) loJResp.EmitCompact = .F. ? "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 return 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") llDeleted = 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") llFollowing = loJResp.BoolOf("following") llMy_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") llInvalid_email = loJResp.BoolOf("invalid_email") llEmail_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") llPrimary = 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") llInvalid_email = loJResp.BoolOf("email[i].invalid_email") llOpt_out = loJResp.BoolOf("email[i].opt_out") llPrimary_address = loJResp.BoolOf("email[i].primary_address") llReply_to_address = loJResp.BoolOf("email[i].reply_to_address") i = i + 1 enddo release loHttp release loJson release loSbResponseBody release loJResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.