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
(PowerBuilder) GetHarvest - List ClientsReturns a list of your clients. For more information, see https://help.getharvest.com/api-v2/clients-api/clients/clients/
integer li_rc oleobject loo_Http integer li_Success oleobject loo_SbResponseBody oleobject loo_JResp integer li_RespStatusCode integer li_Per_page integer li_Total_pages integer li_Total_entries string ls_Next_page string ls_Previous_page integer li_Page string ls_LinksFirst string ls_LinksNext string ls_LinksPrevious string ls_LinksLast integer i integer li_Count_i integer li_Id string ls_Name integer li_Is_active string ls_Address string ls_Created_at string ls_Updated_at string ls_Currency // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") if li_rc < 0 then destroy loo_Http MessageBox("Error","Connecting to COM object failed") return end if // Implements the following CURL command: // curl "https://api.harvestapp.com/v2/clients" \ // -H "Authorization: Bearer ACCESS_TOKEN" \ // -H "Harvest-Account-Id: ACCOUNT_ID" \ // -H "User-Agent: MyApp (yourname@example.com)" loo_Http.SetRequestHeader("User-Agent","MyApp (yourname@example.com)") loo_Http.SetRequestHeader("Authorization","Bearer ACCESS_TOKEN") loo_Http.SetRequestHeader("Harvest-Account-Id","ACCOUNT_ID") loo_SbResponseBody = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder") li_Success = loo_Http.QuickGetSb("https://api.harvestapp.com/v2/clients",loo_SbResponseBody) if li_Success = 0 then Write-Debug loo_Http.LastErrorText destroy loo_Http destroy loo_SbResponseBody return end if loo_JResp = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject") loo_JResp.LoadSb(loo_SbResponseBody) loo_JResp.EmitCompact = 0 Write-Debug "Response Body:" Write-Debug loo_JResp.Emit() li_RespStatusCode = loo_Http.LastStatus Write-Debug "Response Status Code = " + string(li_RespStatusCode) if li_RespStatusCode >= 400 then Write-Debug "Response Header:" Write-Debug loo_Http.LastHeader Write-Debug "Failed." destroy loo_Http destroy loo_SbResponseBody destroy loo_JResp return end if // Sample JSON response: // { // "clients": [ // { // "id": 5735776, // "name": "123 Industries", // "is_active": true, // "address": "123 Main St.\r\nAnytown, LA 71223", // "created_at": "2017-06-26T21:02:12Z", // "updated_at": "2017-06-26T21:34:11Z", // "currency": "EUR" // }, // { // "id": 5735774, // "name": "ABC Corp", // "is_active": true, // "address": "456 Main St.\r\nAnytown, CT 06467", // "created_at": "2017-06-26T21:01:52Z", // "updated_at": "2017-06-26T21:27:07Z", // "currency": "USD" // } // ], // "per_page": 100, // "total_pages": 1, // "total_entries": 2, // "next_page": null, // "previous_page": null, // "page": 1, // "links": { // "first": "https://api.harvestapp.com/v2/clients?page=1&per_page=100", // "next": null, // "previous": null, // "last": "https://api.harvestapp.com/v2/clients?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 li_Per_page = loo_JResp.IntOf("per_page") li_Total_pages = loo_JResp.IntOf("total_pages") li_Total_entries = loo_JResp.IntOf("total_entries") ls_Next_page = loo_JResp.StringOf("next_page") ls_Previous_page = loo_JResp.StringOf("previous_page") li_Page = loo_JResp.IntOf("page") ls_LinksFirst = loo_JResp.StringOf("links.first") ls_LinksNext = loo_JResp.StringOf("links.next") ls_LinksPrevious = loo_JResp.StringOf("links.previous") ls_LinksLast = loo_JResp.StringOf("links.last") i = 0 li_Count_i = loo_JResp.SizeOfArray("clients") do while i < li_Count_i loo_JResp.I = i li_Id = loo_JResp.IntOf("clients[i].id") ls_Name = loo_JResp.StringOf("clients[i].name") li_Is_active = loo_JResp.BoolOf("clients[i].is_active") ls_Address = loo_JResp.StringOf("clients[i].address") ls_Created_at = loo_JResp.StringOf("clients[i].created_at") ls_Updated_at = loo_JResp.StringOf("clients[i].updated_at") ls_Currency = loo_JResp.StringOf("clients[i].currency") i = i + 1 loop destroy loo_Http destroy loo_SbResponseBody destroy loo_JResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.