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
(DataFlex) GetHarvest - Update ContactUpdates the specific contact by setting the values of the parameters passed. Any parameters not provided will be left unchanged. Returns a contact object and a 200 OK response code if the call succeeded. For more information, see https://help.getharvest.com/api-v2/clients-api/clients/contacts/
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 Integer iId String sTitle String sFirst_name String sLast_name String sEmail String sPhone_office String sPhone_mobile String sFax String sCreated_at String sUpdated_at Integer iClientId String sClientName 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 "https://api.harvestapp.com/v2/contacts/CONTACT_ID" \ // -H "Authorization: Bearer ACCESS_TOKEN" \ // -H "Harvest-Account-Id: ACCOUNT_ID" \ // -H "User-Agent: MyApp (yourname@example.com)" \ // -X PATCH \ // -H "Content-Type: application/json" \ // -d '{"title":"Owner"}' // Use this online tool to generate code from sample JSON: // Generate Code to Create JSON // The following JSON is sent in the request body. // { // "title": "Owner" // } Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Get ComUpdateString Of hoJson "title" "Owner" To iSuccess Send ComSetRequestHeader To hoHttp "User-Agent" "MyApp (yourname@example.com)" Send ComSetRequestHeader To hoHttp "Content-Type" "application/json" Send ComSetRequestHeader To hoHttp "Authorization" "Bearer ACCESS_TOKEN" Send ComSetRequestHeader To hoHttp "Harvest-Account-Id" "ACCOUNT_ID" 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 "PATCH" "https://api.harvestapp.com/v2/contacts/CONTACT_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: // { // "id": 4706510, // "title": "Owner", // "first_name": "George", // "last_name": "Frank", // "email": "georgefrank@example.com", // "phone_office": "", // "phone_mobile": "", // "fax": "", // "created_at": "2017-06-26T21:44:57Z", // "updated_at": "2017-06-26T21:46:48Z", // "client": { // "id": 5735776, // "name": "123 Industries" // } // } // 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 ComIntOf Of hoJResp "id" To iId Get ComStringOf Of hoJResp "title" To sTitle Get ComStringOf Of hoJResp "first_name" To sFirst_name Get ComStringOf Of hoJResp "last_name" To sLast_name Get ComStringOf Of hoJResp "email" To sEmail Get ComStringOf Of hoJResp "phone_office" To sPhone_office Get ComStringOf Of hoJResp "phone_mobile" To sPhone_mobile Get ComStringOf Of hoJResp "fax" To sFax Get ComStringOf Of hoJResp "created_at" To sCreated_at Get ComStringOf Of hoJResp "updated_at" To sUpdated_at Get ComIntOf Of hoJResp "client.id" To iClientId Get ComStringOf Of hoJResp "client.name" To sClientName End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.