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 - Get Client ContactsReturns a list of your contacts. For more information, see https://help.getharvest.com/api-v2/clients-api/clients/contacts/
Use ChilkatAx-win32.pkg Procedure Test Handle hoHttp Boolean iSuccess Variant vSbResponseBody Handle hoSbResponseBody Handle hoJResp Integer iRespStatusCode Integer iPer_page Integer iTotal_pages Integer iTotal_entries String sNext_page String sPrevious_page Integer iPage String sLinksFirst String sLinksNext String sLinksPrevious String sLinksLast Integer i Integer iCount_i 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 // 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" \ // -H "Authorization: Bearer ACCESS_TOKEN" \ // -H "Harvest-Account-Id: ACCOUNT_ID" \ // -H "User-Agent: MyApp (yourname@example.com)" Send ComSetRequestHeader To hoHttp "User-Agent" "MyApp (yourname@example.com)" Send ComSetRequestHeader To hoHttp "Authorization" "Bearer ACCESS_TOKEN" Send ComSetRequestHeader To hoHttp "Harvest-Account-Id" "ACCOUNT_ID" Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody If (Not(IsComObjectCreated(hoSbResponseBody))) Begin Send CreateComObject of hoSbResponseBody End Get pvComObject of hoSbResponseBody to vSbResponseBody Get ComQuickGetSb Of hoHttp "https://api.harvestapp.com/v2/contacts" vSbResponseBody To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End 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 ComLastStatus Of hoHttp To iRespStatusCode Showln "Response Status Code = " iRespStatusCode If (iRespStatusCode >= 400) Begin Showln "Response Header:" Get ComLastHeader Of hoHttp To sTemp1 Showln sTemp1 Showln "Failed." Procedure_Return End // Sample JSON response: // { // "contacts": [ // { // "id": 4706479, // "title": "Owner", // "first_name": "Jane", // "last_name": "Doe", // "email": "janedoe@example.com", // "phone_office": "(203) 697-8885", // "phone_mobile": "(203) 697-8886", // "fax": "(203) 697-8887", // "created_at": "2017-06-26T21:20:07Z", // "updated_at": "2017-06-26T21:27:07Z", // "client": { // "id": 5735774, // "name": "ABC Corp" // } // }, // { // "id": 4706453, // "title": "Manager", // "first_name": "Richard", // "last_name": "Roe", // "email": "richardroe@example.com", // "phone_office": "(318) 515-5905", // "phone_mobile": "(318) 515-5906", // "fax": "(318) 515-5907", // "created_at": "2017-06-26T21:06:55Z", // "updated_at": "2017-06-26T21:27:20Z", // "client": { // "id": 5735776, // "name": "123 Industries" // } // } // ], // "per_page": 100, // "total_pages": 1, // "total_entries": 2, // "next_page": null, // "previous_page": null, // "page": 1, // "links": { // "first": "https://api.harvestapp.com/v2/contacts?page=1&per_page=100", // "next": null, // "previous": null, // "last": "https://api.harvestapp.com/v2/contacts?page=1&per_page=100" // } // } // 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 "per_page" To iPer_page Get ComIntOf Of hoJResp "total_pages" To iTotal_pages Get ComIntOf Of hoJResp "total_entries" To iTotal_entries Get ComStringOf Of hoJResp "next_page" To sNext_page Get ComStringOf Of hoJResp "previous_page" To sPrevious_page Get ComIntOf Of hoJResp "page" To iPage Get ComStringOf Of hoJResp "links.first" To sLinksFirst Get ComStringOf Of hoJResp "links.next" To sLinksNext Get ComStringOf Of hoJResp "links.previous" To sLinksPrevious Get ComStringOf Of hoJResp "links.last" To sLinksLast Move 0 To i Get ComSizeOfArray Of hoJResp "contacts" To iCount_i While (i < iCount_i) Set ComI Of hoJResp To i Get ComIntOf Of hoJResp "contacts[i].id" To iId Get ComStringOf Of hoJResp "contacts[i].title" To sTitle Get ComStringOf Of hoJResp "contacts[i].first_name" To sFirst_name Get ComStringOf Of hoJResp "contacts[i].last_name" To sLast_name Get ComStringOf Of hoJResp "contacts[i].email" To sEmail Get ComStringOf Of hoJResp "contacts[i].phone_office" To sPhone_office Get ComStringOf Of hoJResp "contacts[i].phone_mobile" To sPhone_mobile Get ComStringOf Of hoJResp "contacts[i].fax" To sFax Get ComStringOf Of hoJResp "contacts[i].created_at" To sCreated_at Get ComStringOf Of hoJResp "contacts[i].updated_at" To sUpdated_at Get ComIntOf Of hoJResp "contacts[i].client.id" To iClientId Get ComStringOf Of hoJResp "contacts[i].client.name" To sClientName Move (i + 1) To i Loop End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.