Tcl
Tcl
List Plans for a Group
See more Microsoft Tasks and Plans Examples
Demonstrates how to retrieve a list of plannerPlan objects owned by a group object.See https://docs.microsoft.com/en-us/graph/api/plannergroup-list-plans?view=graph-rest-1.0 for more information.
Chilkat Tcl Downloads
load ./chilkat.dll
set success 0
# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
set http [new_CkHttp]
# 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.
set jsonToken [new_CkJsonObject]
set success [CkJsonObject_LoadFile $jsonToken "qa_data/tokens/msGraphGroup.json"]
if {$success == 0} then {
puts [CkJsonObject_lastErrorText $jsonToken]
delete_CkHttp $http
delete_CkJsonObject $jsonToken
exit
}
CkHttp_put_AuthToken $http [CkJsonObject_stringOf $jsonToken "access_token"]
# Send a GET request to https://graph.microsoft.com/v1.0/groups/{group-id}/planner/plans
set strResponse [CkHttp_quickGetStr $http "https://graph.microsoft.com/v1.0/groups/{group-id}/planner/plans"]
if {[CkHttp_get_LastMethodSuccess $http] == 0} then {
puts [CkHttp_lastErrorText $http]
delete_CkHttp $http
delete_CkJsonObject $jsonToken
exit
}
set json [new_CkJsonObject]
CkJsonObject_Load $json $strResponse
CkJsonObject_put_EmitCompact $json 0
if {[CkHttp_get_LastStatus $http] != 200} then {
puts [CkJsonObject_emit $json]
puts "Failed, response status code = [CkHttp_get_LastStatus $http]"
delete_CkHttp $http
delete_CkJsonObject $jsonToken
delete_CkJsonObject $json
exit
}
puts [CkJsonObject_emit $json]
# Sample output:
# (See parsing code below..)
# {
# "value": [
# {
# "createdBy": {
# "application": {
# "id": "95e27074-6c4a-447a-aa24-9d718a0b86fa"
# },
# "user": {
# "id": "ebf3b108-5234-4e22-b93d-656d7dae5874"
# }
# },
# "createdDateTime": "2015-03-30T18:36:49.2407981Z",
# "owner": "ebf3b108-5234-4e22-b93d-656d7dae5874",
# "title": "title-value",
# "id": "xqQg5FS2LkCp935s-FIFm2QAFkHM"
# }
# ]
# }
# Use this online tool to generate parsing code from sample JSON:
# Generate Parsing Code from JSON
set i 0
set count_i [CkJsonObject_SizeOfArray $json "value"]
while {$i < $count_i} {
CkJsonObject_put_I $json $i
set createdByApplicationId [CkJsonObject_stringOf $json "value[i].createdBy.application.id"]
set createdByUserId [CkJsonObject_stringOf $json "value[i].createdBy.user.id"]
set createdDateTime [CkJsonObject_stringOf $json "value[i].createdDateTime"]
set owner [CkJsonObject_stringOf $json "value[i].owner"]
set title [CkJsonObject_stringOf $json "value[i].title"]
set id [CkJsonObject_stringOf $json "value[i].id"]
set i [expr $i + 1]
}
puts "Success."
delete_CkHttp $http
delete_CkJsonObject $jsonToken
delete_CkJsonObject $json