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
(AutoIt) SugarCRM Updating a RecordDemonstrates how to update a record in 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/#Updating_a_Record
; This example assumes the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. $oHttp = ObjCreate("Chilkat.Http") Local $bSuccess ; 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" ; } $oJson = ObjCreate("Chilkat.JsonObject") $oJson.UpdateString("name","Updated Record") $oHttp.SetRequestHeader "Cache-Control","no-cache" $oHttp.SetRequestHeader "OAuth-Token","<access_token>" $oSbRequestBody = ObjCreate("Chilkat.StringBuilder") $oJson.EmitSb($oSbRequestBody) Local $oResp = $oHttp.PTextSb("PUT","http://<site_url>/rest/v10/Accounts/<record_id>",$oSbRequestBody,"utf-8","application/json",False,False) If ($oHttp.LastMethodSuccess = False) Then ConsoleWrite($oHttp.LastErrorText & @CRLF) Exit EndIf $oSbResponseBody = ObjCreate("Chilkat.StringBuilder") $oResp.GetBodySb($oSbResponseBody) $oJResp = ObjCreate("Chilkat.JsonObject") $oJResp.LoadSb($oSbResponseBody) $oJResp.EmitCompact = False ConsoleWrite("Response Body:" & @CRLF) ConsoleWrite($oJResp.Emit() & @CRLF) Local $iRespStatusCode = $oResp.StatusCode ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF) If ($iRespStatusCode >= 400) Then ConsoleWrite("Response Header:" & @CRLF) ConsoleWrite($oResp.Header & @CRLF) ConsoleWrite("Failed." & @CRLF) Exit EndIf ; 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 Local $sId Local $sName Local $sDate_entered Local $sDate_modified Local $sModified_user_id Local $sModified_by_name Local $sModified_user_linkFull_name Local $sModified_user_linkId Local $sModified_user_link_aclDelete Local $sModified_user_link_acl_hash Local $sCreated_by Local $sCreated_by_name Local $sCreated_by_linkFull_name Local $sCreated_by_linkId Local $sCreated_by_link_aclDelete Local $sCreated_by_link_acl_hash Local $sDescription Local $bDeleted Local $sFacebook Local $sTwitter Local $sGoogleplus Local $sAccount_type Local $sIndustry Local $sAnnual_revenue Local $sPhone_fax Local $sBilling_address_street Local $sBilling_address_street_2 Local $sBilling_address_street_3 Local $sBilling_address_street_4 Local $sBilling_address_city Local $sBilling_address_state Local $sBilling_address_postalcode Local $sBilling_address_country Local $sRating Local $sPhone_office Local $sPhone_alternate Local $sWebsite Local $sOwnership Local $sEmployees Local $sTicker_symbol Local $shipping_address_street Local $shipping_address_street_2 Local $shipping_address_street_3 Local $shipping_address_street_4 Local $shipping_address_city Local $shipping_address_state Local $shipping_address_postalcode Local $shipping_address_country Local $sParent_id Local $sic_code Local $sDuns_num Local $sParent_name Local $sMember_ofName Local $sMember_ofId Local $sMember_of_acl_hash Local $sCampaign_id Local $sCampaign_name Local $sCampaign_accountsName Local $sCampaign_accountsId Local $sCampaign_accounts_acl_hash Local $bFollowing Local $bMy_favorite Local $sAssigned_user_id Local $sAssigned_user_name Local $sAssigned_user_linkFull_name Local $sAssigned_user_linkId Local $sAssigned_user_link_acl_hash Local $sTeam_count Local $sTeam_count_linkTeam_count Local $sTeam_count_linkId Local $sTeam_count_link_acl_hash Local $sEmail1 Local $sEmail2 Local $bInvalid_email Local $bEmail_opt_out Local $sEmail_addresses_non_primary Local $sV_module Local $i Local $iCount_i Local $id_int Local $sName_2 Local $bPrimary Local $sEmail_address Local $bOpt_out Local $bPrimary_address Local $bReply_to_address $sId = $oJResp.StringOf("id") $sName = $oJResp.StringOf("name") $sDate_entered = $oJResp.StringOf("date_entered") $sDate_modified = $oJResp.StringOf("date_modified") $sModified_user_id = $oJResp.StringOf("modified_user_id") $sModified_by_name = $oJResp.StringOf("modified_by_name") $sModified_user_linkFull_name = $oJResp.StringOf("modified_user_link.full_name") $sModified_user_linkId = $oJResp.StringOf("modified_user_link.id") $sModified_user_link_aclDelete = $oJResp.StringOf("modified_user_link._acl.delete") $sModified_user_link_acl_hash = $oJResp.StringOf("modified_user_link._acl._hash") $sCreated_by = $oJResp.StringOf("created_by") $sCreated_by_name = $oJResp.StringOf("created_by_name") $sCreated_by_linkFull_name = $oJResp.StringOf("created_by_link.full_name") $sCreated_by_linkId = $oJResp.StringOf("created_by_link.id") $sCreated_by_link_aclDelete = $oJResp.StringOf("created_by_link._acl.delete") $sCreated_by_link_acl_hash = $oJResp.StringOf("created_by_link._acl._hash") $sDescription = $oJResp.StringOf("description") $bDeleted = $oJResp.BoolOf("deleted") $sFacebook = $oJResp.StringOf("facebook") $sTwitter = $oJResp.StringOf("twitter") $sGoogleplus = $oJResp.StringOf("googleplus") $sAccount_type = $oJResp.StringOf("account_type") $sIndustry = $oJResp.StringOf("industry") $sAnnual_revenue = $oJResp.StringOf("annual_revenue") $sPhone_fax = $oJResp.StringOf("phone_fax") $sBilling_address_street = $oJResp.StringOf("billing_address_street") $sBilling_address_street_2 = $oJResp.StringOf("billing_address_street_2") $sBilling_address_street_3 = $oJResp.StringOf("billing_address_street_3") $sBilling_address_street_4 = $oJResp.StringOf("billing_address_street_4") $sBilling_address_city = $oJResp.StringOf("billing_address_city") $sBilling_address_state = $oJResp.StringOf("billing_address_state") $sBilling_address_postalcode = $oJResp.StringOf("billing_address_postalcode") $sBilling_address_country = $oJResp.StringOf("billing_address_country") $sRating = $oJResp.StringOf("rating") $sPhone_office = $oJResp.StringOf("phone_office") $sPhone_alternate = $oJResp.StringOf("phone_alternate") $sWebsite = $oJResp.StringOf("website") $sOwnership = $oJResp.StringOf("ownership") $sEmployees = $oJResp.StringOf("employees") $sTicker_symbol = $oJResp.StringOf("ticker_symbol") $shipping_address_street = $oJResp.StringOf("shipping_address_street") $shipping_address_street_2 = $oJResp.StringOf("shipping_address_street_2") $shipping_address_street_3 = $oJResp.StringOf("shipping_address_street_3") $shipping_address_street_4 = $oJResp.StringOf("shipping_address_street_4") $shipping_address_city = $oJResp.StringOf("shipping_address_city") $shipping_address_state = $oJResp.StringOf("shipping_address_state") $shipping_address_postalcode = $oJResp.StringOf("shipping_address_postalcode") $shipping_address_country = $oJResp.StringOf("shipping_address_country") $sParent_id = $oJResp.StringOf("parent_id") $sic_code = $oJResp.StringOf("sic_code") $sDuns_num = $oJResp.StringOf("duns_num") $sParent_name = $oJResp.StringOf("parent_name") $sMember_ofName = $oJResp.StringOf("member_of.name") $sMember_ofId = $oJResp.StringOf("member_of.id") $sMember_of_acl_hash = $oJResp.StringOf("member_of._acl._hash") $sCampaign_id = $oJResp.StringOf("campaign_id") $sCampaign_name = $oJResp.StringOf("campaign_name") $sCampaign_accountsName = $oJResp.StringOf("campaign_accounts.name") $sCampaign_accountsId = $oJResp.StringOf("campaign_accounts.id") $sCampaign_accounts_acl_hash = $oJResp.StringOf("campaign_accounts._acl._hash") $bFollowing = $oJResp.BoolOf("following") $bMy_favorite = $oJResp.BoolOf("my_favorite") $sAssigned_user_id = $oJResp.StringOf("assigned_user_id") $sAssigned_user_name = $oJResp.StringOf("assigned_user_name") $sAssigned_user_linkFull_name = $oJResp.StringOf("assigned_user_link.full_name") $sAssigned_user_linkId = $oJResp.StringOf("assigned_user_link.id") $sAssigned_user_link_acl_hash = $oJResp.StringOf("assigned_user_link._acl._hash") $sTeam_count = $oJResp.StringOf("team_count") $sTeam_count_linkTeam_count = $oJResp.StringOf("team_count_link.team_count") $sTeam_count_linkId = $oJResp.StringOf("team_count_link.id") $sTeam_count_link_acl_hash = $oJResp.StringOf("team_count_link._acl._hash") $sEmail1 = $oJResp.StringOf("email1") $sEmail2 = $oJResp.StringOf("email2") $bInvalid_email = $oJResp.BoolOf("invalid_email") $bEmail_opt_out = $oJResp.BoolOf("email_opt_out") $sEmail_addresses_non_primary = $oJResp.StringOf("email_addresses_non_primary") $sV_module = $oJResp.StringOf("_module") $i = 0 $iCount_i = $oJResp.SizeOfArray("modified_user_link._acl.fields") While $i < $iCount_i $oJResp.I = $i $i = $i + 1 Wend $i = 0 $iCount_i = $oJResp.SizeOfArray("created_by_link._acl.fields") While $i < $iCount_i $oJResp.I = $i $i = $i + 1 Wend $i = 0 $iCount_i = $oJResp.SizeOfArray("member_of._acl.fields") While $i < $iCount_i $oJResp.I = $i $i = $i + 1 Wend $i = 0 $iCount_i = $oJResp.SizeOfArray("campaign_accounts._acl.fields") While $i < $iCount_i $oJResp.I = $i $i = $i + 1 Wend $i = 0 $iCount_i = $oJResp.SizeOfArray("tag") While $i < $iCount_i $oJResp.I = $i $i = $i + 1 Wend $i = 0 $iCount_i = $oJResp.SizeOfArray("assigned_user_link._acl.fields") While $i < $iCount_i $oJResp.I = $i $i = $i + 1 Wend $i = 0 $iCount_i = $oJResp.SizeOfArray("team_count_link._acl.fields") While $i < $iCount_i $oJResp.I = $i $i = $i + 1 Wend $i = 0 $iCount_i = $oJResp.SizeOfArray("team_name") While $i < $iCount_i $oJResp.I = $i $id_int = $oJResp.IntOf("team_name[i].id") $sName = $oJResp.StringOf("team_name[i].name") $sName_2 = $oJResp.StringOf("team_name[i].name_2") $bPrimary = $oJResp.BoolOf("team_name[i].primary") $i = $i + 1 Wend $i = 0 $iCount_i = $oJResp.SizeOfArray("email") While $i < $iCount_i $oJResp.I = $i $sEmail_address = $oJResp.StringOf("email[i].email_address") $bInvalid_email = $oJResp.BoolOf("email[i].invalid_email") $bOpt_out = $oJResp.BoolOf("email[i].opt_out") $bPrimary_address = $oJResp.BoolOf("email[i].primary_address") $bReply_to_address = $oJResp.BoolOf("email[i].reply_to_address") $i = $i + 1 Wend |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.