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 - Get Client ContactsReturns a list of your contacts. For more information, see https://help.getharvest.com/api-v2/clients-api/clients/contacts/
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_Title string ls_First_name string ls_Last_name string ls_Email string ls_Phone_office string ls_Phone_mobile string ls_Fax string ls_Created_at string ls_Updated_at integer li_ClientId string ls_ClientName // 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/contacts" \ // -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/contacts",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: // { // "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 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("contacts") do while i < li_Count_i loo_JResp.I = i li_Id = loo_JResp.IntOf("contacts[i].id") ls_Title = loo_JResp.StringOf("contacts[i].title") ls_First_name = loo_JResp.StringOf("contacts[i].first_name") ls_Last_name = loo_JResp.StringOf("contacts[i].last_name") ls_Email = loo_JResp.StringOf("contacts[i].email") ls_Phone_office = loo_JResp.StringOf("contacts[i].phone_office") ls_Phone_mobile = loo_JResp.StringOf("contacts[i].phone_mobile") ls_Fax = loo_JResp.StringOf("contacts[i].fax") ls_Created_at = loo_JResp.StringOf("contacts[i].created_at") ls_Updated_at = loo_JResp.StringOf("contacts[i].updated_at") li_ClientId = loo_JResp.IntOf("contacts[i].client.id") ls_ClientName = loo_JResp.StringOf("contacts[i].client.name") i = i + 1 loop destroy loo_Http destroy loo_SbResponseBody destroy loo_JResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.