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
(Lianja) GetHarvest - Test Personal Access TokenDemonstrates how to test your GetHarvest Personal Access Token
// This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loHttp = createobject("CkHttp") loHttp.SetRequestHeader("User-Agent","Harvest API Example") loHttp.SetRequestHeader("Harvest-Account-ID","ACCOUNT_ID") loHttp.SetRequestHeader("Authorization","Bearer ACCESS_TOKEN") loSbResponseBody = createobject("CkStringBuilder") llSuccess = loHttp.QuickGetSb("https://api.harvestapp.com/api/v2/users/me.json",loSbResponseBody) if (llSuccess <> .T.) then ? loHttp.LastErrorText release loHttp release loSbResponseBody return endif loJResp = createobject("CkJsonObject") loJResp.LoadSb(loSbResponseBody) loJResp.EmitCompact = .F. ? "Response Body:" ? loJResp.Emit() lnRespStatusCode = loHttp.LastStatus ? "Response Status Code = " + str(lnRespStatusCode) if (lnRespStatusCode >= 400) then ? "Response Header:" ? loHttp.LastResponseHeader release loHttp release loSbResponseBody release loJResp return endif // Sample JSON response: // { // "id": 2826142, // "first_name": "Joe", // "last_name": "Johnson", // "email": "joe@example.com", // "telephone": "", // "timezone": "Central Time (US & Canada)", // "weekly_capacity": 126000, // "has_access_to_all_future_projects": false, // "is_contractor": false, // "is_admin": true, // "is_project_manager": false, // "can_see_rates": true, // "can_create_projects": true, // "can_create_invoices": true, // "is_active": true, // "created_at": "2019-06-06T15:57:58Z", // "updated_at": "2019-06-06T15:58:32Z", // "default_hourly_rate": 175.0, // "cost_rate": 60.0, // "roles": [ // "role1", // "role2" // ], // "avatar_url": "https://d3s3969qhosaug.cloudfront.net/default-avatars/4d46.png?1559836678" // } // Sample code for parsing the JSON response... // Use the following online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON lnId = loJResp.IntOf("id") lcFirst_name = loJResp.StringOf("first_name") lcLast_name = loJResp.StringOf("last_name") lcEmail = loJResp.StringOf("email") lcTelephone = loJResp.StringOf("telephone") lcTimezone = loJResp.StringOf("timezone") lnWeekly_capacity = loJResp.IntOf("weekly_capacity") llHas_access_to_all_future_projects = loJResp.BoolOf("has_access_to_all_future_projects") llIs_contractor = loJResp.BoolOf("is_contractor") llIs_admin = loJResp.BoolOf("is_admin") llIs_project_manager = loJResp.BoolOf("is_project_manager") llCan_see_rates = loJResp.BoolOf("can_see_rates") llCan_create_projects = loJResp.BoolOf("can_create_projects") llCan_create_invoices = loJResp.BoolOf("can_create_invoices") llIs_active = loJResp.BoolOf("is_active") lcCreated_at = loJResp.StringOf("created_at") lcUpdated_at = loJResp.StringOf("updated_at") lcDefault_hourly_rate = loJResp.StringOf("default_hourly_rate") lcCost_rate = loJResp.StringOf("cost_rate") lcAvatar_url = loJResp.StringOf("avatar_url") i = 0 lnCount_i = loJResp.SizeOfArray("roles") do while i < lnCount_i loJResp.I = i lcStrVal = loJResp.StringOf("roles[i]") i = i + 1 enddo release loHttp release loSbResponseBody release loJResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.