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
(AutoIt) 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. $oHttp = ObjCreate("Chilkat.Http") Local $bSuccess $oHttp.SetRequestHeader "User-Agent","Harvest API Example" $oHttp.SetRequestHeader "Harvest-Account-ID","ACCOUNT_ID" $oHttp.SetRequestHeader "Authorization","Bearer ACCESS_TOKEN" $oSbResponseBody = ObjCreate("Chilkat.StringBuilder") $bSuccess = $oHttp.QuickGetSb("https://api.harvestapp.com/api/v2/users/me.json",$oSbResponseBody) If ($bSuccess <> True) Then ConsoleWrite($oHttp.LastErrorText & @CRLF) Exit EndIf $oJResp = ObjCreate("Chilkat.JsonObject") $oJResp.LoadSb($oSbResponseBody) $oJResp.EmitCompact = False ConsoleWrite("Response Body:" & @CRLF) ConsoleWrite($oJResp.Emit() & @CRLF) Local $iRespStatusCode = $oHttp.LastStatus ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF) If ($iRespStatusCode >= 400) Then ConsoleWrite("Response Header:" & @CRLF) ConsoleWrite($oHttp.LastResponseHeader & @CRLF) Exit 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 Local $id Local $sFirst_name Local $sLast_name Local $sEmail Local $sTelephone Local $sTimezone Local $iWeekly_capacity Local $bHas_access_to_all_future_projects Local $bIs_contractor Local $bIs_admin Local $bIs_project_manager Local $bCan_see_rates Local $bCan_create_projects Local $bCan_create_invoices Local $bIs_active Local $sCreated_at Local $sUpdated_at Local $sDefault_hourly_rate Local $sCost_rate Local $sAvatar_url Local $i Local $iCount_i Local $strVal $id = $oJResp.IntOf("id") $sFirst_name = $oJResp.StringOf("first_name") $sLast_name = $oJResp.StringOf("last_name") $sEmail = $oJResp.StringOf("email") $sTelephone = $oJResp.StringOf("telephone") $sTimezone = $oJResp.StringOf("timezone") $iWeekly_capacity = $oJResp.IntOf("weekly_capacity") $bHas_access_to_all_future_projects = $oJResp.BoolOf("has_access_to_all_future_projects") $bIs_contractor = $oJResp.BoolOf("is_contractor") $bIs_admin = $oJResp.BoolOf("is_admin") $bIs_project_manager = $oJResp.BoolOf("is_project_manager") $bCan_see_rates = $oJResp.BoolOf("can_see_rates") $bCan_create_projects = $oJResp.BoolOf("can_create_projects") $bCan_create_invoices = $oJResp.BoolOf("can_create_invoices") $bIs_active = $oJResp.BoolOf("is_active") $sCreated_at = $oJResp.StringOf("created_at") $sUpdated_at = $oJResp.StringOf("updated_at") $sDefault_hourly_rate = $oJResp.StringOf("default_hourly_rate") $sCost_rate = $oJResp.StringOf("cost_rate") $sAvatar_url = $oJResp.StringOf("avatar_url") $i = 0 $iCount_i = $oJResp.SizeOfArray("roles") While $i < $iCount_i $oJResp.I = $i $strVal = $oJResp.StringOf("roles[i]") $i = $i + 1 Wend |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.