AutoIt
AutoIt
Outlook Calendar List Calendars
See more Outlook Calendar Examples
Get all the user's calendars.Chilkat AutoIt Downloads
Local $bSuccess = False
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
; Use your previously obtained access token here: Get Outlook Calendar OAuth2 Access Token (Azure AD v2.0 Endpoint).
$oJsonToken = ObjCreate("Chilkat.JsonObject")
$bSuccess = $oJsonToken.LoadFile("qa_data/tokens/outlookCalendar.json")
If ($bSuccess = False) Then
ConsoleWrite($oJsonToken.LastErrorText & @CRLF)
Exit
EndIf
$oHttp.AuthToken = $oJsonToken.StringOf("access_token")
$oResp = ObjCreate("Chilkat.HttpResponse")
$bSuccess = $oHttp.HttpNoBody("GET","https://graph.microsoft.com/v1.0/me/calendars",$oResp)
If ($bSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite("Response status code = " & $oResp.StatusCode & @CRLF)
; The HTTP request succeeded if the response status code = 200.
If ($oResp.StatusCode <> 200) Then
ConsoleWrite($oResp.BodyStr & @CRLF)
ConsoleWrite("Failed" & @CRLF)
Exit
EndIf
$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.Load($oResp.BodyStr)
$oJson.EmitCompact = False
ConsoleWrite($oJson.Emit() & @CRLF)
; Here is a sample response:
; Use this online tool to generate parsing code from sample JSON:
; Generate Parsing Code from JSON
; {
; "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#me/calendars",
; "value": [
; {
; "@odata.id": "https://graph.microsoft.com/v1.0/users('ddfcd489-628b-40d7-b48b-57002df800e5@1717622f-1d94-4d0c-9d74-709fad664b77')/calendars('AAMkAGI2TGuLAAA=')",
; "id": "AAMkAGI2TGuLAAA=",
; "name": "Calendar",
; "color": "auto",
; "changeKey": "nfZyf7VcrEKLNoU37KWlkQAAA0x0+w==",
; "canShare":true,
; "canViewPrivateItems":true,
; "hexColor": "",
; "canEdit":true,
; "allowedOnlineMeetingProviders": [
; "teamsForBusiness"
; ],
; "defaultOnlineMeetingProvider": "teamsForBusiness",
; "isTallyingResponses": true,
; "isRemovable": false,
; "owner":{
; "name":"Samantha Booth",
; "address":"samanthab@adatum.onmicrosoft.com"
; }
; }
; ]
; }
Local $sId
Local $sName
Local $sColor
Local $sHexColor
Local $bIsDefaultCalendar
Local $sChangeKey
Local $bCanShare
Local $bCanViewPrivateItems
Local $bCanEdit
Local $sDefaultOnlineMeetingProvider
Local $bIsTallyingResponses
Local $bIsRemovable
Local $sOwnerName
Local $sOwnerAddress
Local $iJ
Local $iCount_j
Local $strVal
Local $sOdata_context = $oJson.StringOf("""@odata.context""")
Local $i = 0
Local $iCount_i = $oJson.SizeOfArray("value")
While $i < $iCount_i
$oJson.I = $i
$sId = $oJson.StringOf("value[i].id")
$sName = $oJson.StringOf("value[i].name")
$sColor = $oJson.StringOf("value[i].color")
$sHexColor = $oJson.StringOf("value[i].hexColor")
$bIsDefaultCalendar = $oJson.BoolOf("value[i].isDefaultCalendar")
$sChangeKey = $oJson.StringOf("value[i].changeKey")
$bCanShare = $oJson.BoolOf("value[i].canShare")
$bCanViewPrivateItems = $oJson.BoolOf("value[i].canViewPrivateItems")
$bCanEdit = $oJson.BoolOf("value[i].canEdit")
$sDefaultOnlineMeetingProvider = $oJson.StringOf("value[i].defaultOnlineMeetingProvider")
$bIsTallyingResponses = $oJson.BoolOf("value[i].isTallyingResponses")
$bIsRemovable = $oJson.BoolOf("value[i].isRemovable")
$sOwnerName = $oJson.StringOf("value[i].owner.name")
$sOwnerAddress = $oJson.StringOf("value[i].owner.address")
$iJ = 0
$iCount_j = $oJson.SizeOfArray("value[i].allowedOnlineMeetingProviders")
While $iJ < $iCount_j
$oJson.J = $iJ
$strVal = $oJson.StringOf("value[i].allowedOnlineMeetingProviders[j]")
$iJ = $iJ + 1
Wend
$i = $i + 1
Wend