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 - Test Personal Access TokenDemonstrates how to test your GetHarvest Personal Access Token
Use ChilkatAx-win32.pkg Procedure Test Handle hoHttp Boolean iSuccess Variant vSbResponseBody Handle hoSbResponseBody Handle hoJResp Integer iRespStatusCode Integer iId String sFirst_name String sLast_name String sEmail String sTelephone String sTimezone Integer iWeekly_capacity Boolean iHas_access_to_all_future_projects Boolean iIs_contractor Boolean iIs_admin Boolean iIs_project_manager Boolean iCan_see_rates Boolean iCan_create_projects Boolean iCan_create_invoices Boolean iIs_active String sCreated_at String sUpdated_at String sDefault_hourly_rate String sCost_rate String sAvatar_url Integer i Integer iCount_i String sStrVal 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 Send ComSetRequestHeader To hoHttp "User-Agent" "Harvest API Example" Send ComSetRequestHeader To hoHttp "Harvest-Account-ID" "ACCOUNT_ID" Send ComSetRequestHeader To hoHttp "Authorization" "Bearer ACCESS_TOKEN" 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/api/v2/users/me.json" vSbResponseBody To iSuccess If (iSuccess <> True) 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 ComLastResponseHeader Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End // 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 Get ComIntOf Of hoJResp "id" To iId 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 "telephone" To sTelephone Get ComStringOf Of hoJResp "timezone" To sTimezone Get ComIntOf Of hoJResp "weekly_capacity" To iWeekly_capacity Get ComBoolOf Of hoJResp "has_access_to_all_future_projects" To iHas_access_to_all_future_projects Get ComBoolOf Of hoJResp "is_contractor" To iIs_contractor Get ComBoolOf Of hoJResp "is_admin" To iIs_admin Get ComBoolOf Of hoJResp "is_project_manager" To iIs_project_manager Get ComBoolOf Of hoJResp "can_see_rates" To iCan_see_rates Get ComBoolOf Of hoJResp "can_create_projects" To iCan_create_projects Get ComBoolOf Of hoJResp "can_create_invoices" To iCan_create_invoices Get ComBoolOf Of hoJResp "is_active" To iIs_active Get ComStringOf Of hoJResp "created_at" To sCreated_at Get ComStringOf Of hoJResp "updated_at" To sUpdated_at Get ComStringOf Of hoJResp "default_hourly_rate" To sDefault_hourly_rate Get ComStringOf Of hoJResp "cost_rate" To sCost_rate Get ComStringOf Of hoJResp "avatar_url" To sAvatar_url Move 0 To i Get ComSizeOfArray Of hoJResp "roles" To iCount_i While (i < iCount_i) Set ComI Of hoJResp To i Get ComStringOf Of hoJResp "roles[i]" To sStrVal Move (i + 1) To i Loop End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.