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
(PureBasic) Get Tasks for UserDemonstrates how to retrieve a list of plannertask objects assigned to a User. See https://docs.microsoft.com/en-us/graph/api/planneruser-list-tasks?view=graph-rest-1.0 for more information.
IncludeFile "CkJsonObject.pb" IncludeFile "CkHttp.pb" Procedure ChilkatExample() ; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. http.i = CkHttp::ckCreate() If http.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; The Microsoft Planner REST API requires an OAuth2 token with the Group.ReadWrite.All scope. ; Use your previously obtained access token as shown here: ; Get Microsoft Graph OAuth2 Access Token with Group.ReadWrite.All scope. jsonToken.i = CkJsonObject::ckCreate() If jsonToken.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i = CkJsonObject::ckLoadFile(jsonToken,"qa_data/tokens/msGraphGroup.json") If success = 0 Debug CkJsonObject::ckLastErrorText(jsonToken) CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) ProcedureReturn EndIf CkHttp::setCkAuthToken(http, CkJsonObject::ckStringOf(jsonToken,"access_token")) ; Send a GET request to https://graph.microsoft.com/v1.0/me/planner/tasks strResponse.s = CkHttp::ckQuickGetStr(http,"https://graph.microsoft.com/v1.0/me/planner/tasks") If CkHttp::ckLastMethodSuccess(http) = 0 Debug CkHttp::ckLastErrorText(http) CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) ProcedureReturn EndIf json.i = CkJsonObject::ckCreate() If json.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckLoad(json,strResponse) CkJsonObject::setCkEmitCompact(json, 0) If CkHttp::ckLastStatus(http) <> 200 Debug CkJsonObject::ckEmit(json) Debug "Failed, response status code = " + Str(CkHttp::ckLastStatus(http)) CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) CkJsonObject::ckDispose(json) ProcedureReturn EndIf Debug CkJsonObject::ckEmit(json) ; Sample output: ; (See parsing code below..) ; { ; "value": [ ; { ; "createdBy": { ; "user": { ; "id": "6463a5ce-2119-4198-9f2a-628761df4a62" ; } ; }, ; "planId": "xqQg5FS2LkCp935s-FIFm2QAFkHM", ; "bucketId": "gcrYAaAkgU2EQUvpkNNXLGQAGTtu", ; "title": "title-value", ; "orderHint": "9223370609546166567W", ; "assigneePriority": "90057581\"", ; "createdDateTime": "2015-03-25T18:36:49.2407981Z", ; "assignments": { ; "fbab97d0-4932-4511-b675-204639209557": { ; "@odata.type": "#microsoft.graph.plannerAssignment", ; "assignedBy": { ; "user": { ; "id": "1e9955d2-6acd-45bf-86d3-b546fdc795eb" ; } ; }, ; "assignedDateTime": "2015-03-25T18:38:21.956Z", ; "orderHint": "RWk1" ; } ; }, ; "id":"01gzSlKkIUSUl6DF_EilrmQAKDhh" ; } ; ] ; } i.i count_i.i createdByUserId.s planId.s bucketId.s title.s orderHint.s assigneePriority.s createdDateTime.s assignments_odataType.s assignmentsAssignedByUserId.s assignmentsAssignedDateTime.s assignmentsOrderHint.s id.s i = 0 count_i = CkJsonObject::ckSizeOfArray(json,"value") While i < count_i CkJsonObject::setCkI(json, i) createdByUserId = CkJsonObject::ckStringOf(json,"value[i].createdBy.user.id") planId = CkJsonObject::ckStringOf(json,"value[i].planId") bucketId = CkJsonObject::ckStringOf(json,"value[i].bucketId") title = CkJsonObject::ckStringOf(json,"value[i].title") orderHint = CkJsonObject::ckStringOf(json,"value[i].orderHint") assigneePriority = CkJsonObject::ckStringOf(json,"value[i].assigneePriority") createdDateTime = CkJsonObject::ckStringOf(json,"value[i].createdDateTime") jsonA.i = CkJsonObject::ckObjectOf(json,"value[i].assignments") userId.s = CkJsonObject::ckNameAt(jsonA,0) jsonUserA.i = CkJsonObject::ckObjectOf(jsonA,userId) assignments_odataType = CkJsonObject::ckStringOf(jsonUserA,Chr(34) + "@odata.type" + Chr(34)) assignmentsAssignedByUserId = CkJsonObject::ckStringOf(jsonUserA,"assignedBy.user.id") assignmentsAssignedDateTime = CkJsonObject::ckStringOf(jsonUserA,"assignedDateTime") assignmentsOrderHint = CkJsonObject::ckStringOf(jsonUserA,"orderHint") CkJsonObject::ckDispose(jsonUserA) CkJsonObject::ckDispose(jsonA) id = CkJsonObject::ckStringOf(json,"value[i].id") i = i + 1 Wend Debug "Success." CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) CkJsonObject::ckDispose(json) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.